scheduling ftp transfers

scheduling ftp transfers

Post by Cap'n Bil » Fri, 12 Dec 1997 04:00:00



Run expect as a cron job



Quote:> Today most servers are ftp. Is there a way to have a scheduled unattended
> file transfer to/from ftp servers?

 
 
 

scheduling ftp transfers

Post by Chris Hil » Fri, 12 Dec 1997 04:00:00


The way I do it is to have a cron job run a shell script at a specified
time.  In the shell script you can easily automate ftp.  To do it,
create a file called .netrc the home directory of the user who will have
the cron running.  An example of the file would be:

   machine pooh.bear.com  login foo password bar

Set the file with permissions of 600 (rw-------) and owned by you.  In
your script, you would enter 'ftp pooh.bear.com'.  Ftp will
automatically look for your .netrc file and if it finds a machine with
the same name as it was invoked with, it will attempt to open that
host.  When it does it will perform an automatic login with the login
and password provided in the file.  In this case, foo for the login and
bar for the pasword.

That gets you into the site.  Now to do something, you need to create
another file, call it commands.ftp.  It could contain whatever normal
ftp commands you would have entered by hand at the ftp> prompt.  For
example:

cd /somedirectory
put somefile
quit

Now in your cron-invoked script, you would have the line

       ftp pooh.bear.com < commands.ftp >> logfile.out  2>&1

This will automatically log you into pooh.bear.com, execute the commands
in the commands.ftp file and exit ftp and continue on in your script.
The results of what it did can be found in the file logfile.out.  You
can then grep the logfile.out for any error related ftp command codes
such as 4xx and 5xx to check for success or failure.  I dont know of a
way to make ftp set an exit status!

This sounds difficult, but it actually works very well and is easy to
monitor.  Also without doing no more coding than a simple shell script.
If you need more info, email me and I will mail you actual examples from
our production system to get you started.

Expect will work well also, but you may have to do a little coding to
perform your task.

Good Luck...



> Run expect as a cron job



> > Today most servers are ftp. Is there a way to have a scheduled
> unattended
> > file transfer to/from ftp servers?


 
 
 

scheduling ftp transfers

Post by S. L » Fri, 12 Dec 1997 04:00:00




>Run expect as a cron job



>> Today most servers are ftp. Is there a way to have a scheduled unattended
>> file transfer to/from ftp servers?

  Or use ncftpget and ncftpput, check http://www.ncftp.com.

--
---  <A HREF="http://weber.u.washington.edu/~link"> Optik Nirvana </A>  ---

 
 
 

scheduling ftp transfers

Post by bill davids » Sat, 13 Dec 1997 04:00:00



| In the old days of UUCP one could schedule a particular transfer at a
| particular time. If the transfer failed it was automatically retried
| according to your settings. It was even possible to have the same
| transfer occur daily by putting something in the cron file.
|
| Today most servers are ftp. Is there a way to have a scheduled unattended
| file transfer to/from ftp servers?

Put your login and password info int your ~/.netrc file, and chmod
600. See the man page. Now you can run various tiny scripts out of
cron.

Ex, send all new files to a server:

  #!/bin/bash
  #
  # mark the start of this upload
  touch markfile.new
  # build the list of files
  list=$(find . -type f -newer markfile -print)
  # send them
  ftp -v <<XX && mv markfile.new markfile
  cd upload-dir
  mput $list
  quit
  XX

Do note the ftp "newer" command for pulling updates.
--

  What do you mean I shouldn't do thing like that at my age? At my
age if you don't do things like that you might die of natural
causes or boredom!