ITEM: Q6036L

How to create unattended FTP sessions.


Response:

The customer would like to be able to do an ftp transfer without any
user interaction (i.e., kick it off from cron).  Following are the
steps that are required for such a task.

1) Create a .netrc file in your home directory, or the directory from
   which you will be initiating the file transfer from.  This is the
   local system.

   The file format of this file is:

   machine \ user \ password \ macdef
   init
   \
   bye
   \

   For example:

   machine hercules login john password doe macdef
   init
   lcd /tmp/test
   mget u*
   bye

   machine aristotle login jane password doe

   When executed this file will automatically login the user john
   using the password doe to the system hercules.  "init" is the name 
   of a special macro that is executed immediately upon login
   to the system.  The command "lcd /tmp/test" causes the local
   directory to be changed to /tmp/test (this is where incoming files 
   will be stored).  The command "mget u*" retrieves all files in the 
   remote directory that start with the letter "u".  The command "bye"
   terminates the ftp session.  It is essential that the last command 
   be followed by a blank line for the macro to execute correctly.

2) Change the ownership on the .netrc file to R/W for owner only.

   (i.e., chmod 600 .netrc)

3) You may now start ftp in the following way:

   ftp -i hercules

   The "-i" flag turns interactive mode off.  The user is not required
   to input anything in the process.  ftp checks the current directory, then
   the local users $HOME directory for a .netrc file.  When it finds
   the file it will process the line in the file corresponding to the
   system name specified in the ftp command.  This command could then be
   placed into a crontab and run at a later time.


Support Line: How to create unattended FTP sessions. ITEM: Q6036L
Dated: January 1995 Category: N/A
This HTML file was generated 99/06/24~13:30:37
Comments or suggestions? Contact us