Automating Your FTP Session

Home Page
Search
Site Contents


Automating Your FTP Session

  • Are you trying to connect during peak hours? Web and FTP downloads will be slower during peak hours (11am - 3pm Monday through Friday, Eastern Time). Try scheduling your downloads for non-peak hours. Automating is easy if you are using Windows NT or Windows 95.
Here is one way to automate FTP downloads. Automating downloads has two main steps:
  1. Make a script to perform the ftp portion of the transaction
  2. Schedule the script file to run at a pre-set time

  1. Step One: Write the ftp script file
    Here is a simple 7-line script file:
    open ftp.commandcom.com
    user username
    password
    cd products/commercial/f-prot95
    bin
    get fpcurrent.zip
    bye
    

    Here is an explanation of each line:

    open ftp.commandcom.com indicates the server you are connecting to
    user username sends your username
    password sends your password
    cd products/commercial/f-prot indicates the directory path you want to use
    bin changes the mode to binary
    get fpcurrent.zip indicates what file you want to get
    bye disconnects
    exit exits from DOS

    Users should write the script in Notepad or other text editor, save it as a .ftp file, for example, then modify the text file to show their own variables, paths, passwords, multiple files, etc.

  2. Step Two: Schedule the script file to run
    • You can execute the above script "autoftp.ftp" immediately with the following DOS command in WinNT or Win95 (using the built-in ftp client):
      C:\> ftp -n -s:autoftp.ftp
      
      In this case, -n stops the ftp client from asking for a username, instead of pulling it from the script. The switch -s tells the ftp program to use the script file provided to get its commands.
    • To automate the script "autoftp.ftp", you must set up some method of scheduling. Scheduling permits commands to be run while the computer is on, but is unattended. Optimal time periods for connecting to our FTP server for this type of activity would be from 3:00 a.m. - 5:30 a.m. daily or over the weekend.
Windows NT

It is possible to use the "AT" command in WinNT to schedule jobs. Here are the guidelines for using AT:

a. The Schedule service must be running to use the AT command (go to Control Panel|Services to start the Schedule service)
b. The first time you set the AT command, you should type something like this:

C:\> AT 3am /next:Thursday "ftp -n -s:autoftp.ftp"
Where you are following these guidelines:


/every:date [,...] Runs the command on each specified day(s) of the week or month. If date is omitted, the current day of the month is assumed.
/next:date[,...] Runs the specified command on the next occurrence of the day (for example, next Thursday). If date is omitted, the current day of the month is assumed.
"command" Is the Windows NT command, or batch program to be run.

c. To see the scheduled jobs on your local machine, just type:

C:\> AT
Status ID   Day                     Time          Command Line
-------------------------------------------------------------------------------
        0   Next Th                 3:00 AM       "ftp -n -s:autoftp.ftp"
        1   Next Tu                 3:00 AM       "ftp -n -s:autoftp.ftp"

Windows 95

To schedule jobs in Windows 95, use the System Agent.

NOTE:

No matter which scheduling tool you use, do not forget to disable the schedule after its use. In most cases, you won't want the scheduled program to run more than once.