Create Scheduled FTP Job in Windows
September 19th, 2006
There is usually more than one way to accomplish this task, but I have struggled with how to create a scheduled ftp job in Windows for a long time.
I recently ran into a problem which forced me to figure out how to create a scheduled ftp job. I needed to post results from my fantasy football league draft to a website so the slackers who couldn’t be at the live draft could more easily follow along and know who had been drafted so far. The software I use to conduct my draft (FFLM) can automatically generate HTML reports after each pick. I needed to create an FTP job that would take those HTML reports and post them to a website for the remote drafters to see.
I’ve used Linux and cron before, and I was hoping to get something like that in Windows. Although it’s not too difficult in Windows, I needed to do a little research to figure out how to create a scheduled ftp job.
I found an article on the Microsoft Help and Support site that shows how to use an FTP Batch script. If you open up Notepad, you can create a simple file that contains all of the commands you need to type in for your ftp job. Just type in the commands you would use in the ftp command-line utility. For example, my .scr file looks something like this:
open 10.0.0.1
user
password
lcd "C:\Files\ToFTP"
cd website/Fantasy/Football/Directory
put DraftResults.htm
put TeamRosters.htm
bye
The first line connects to the FTP server, the second and third lines are the username and password to connect to the server. The fourth line changes my local dirctory to C:\Files\ToFTP, where my files are located. The fifth line gets to the proper directory in the FTP server, it’s where my files are going to be placed. The sixth and seventh lines transfer the two report files to the server. The eighth line disconnects from the server.
Saving this file as a .scr file means that I now have an FTP script to run. From the command line I can simply type:
ftp -s:Test.scr
The script will run and the two files will be placed on the server.
Now that we have the ftp script, it’s time to automate it. All we need to do is create a very simple batch file. Again, this can be done simply using Notepad. The batch file will basically run the ftp command line script as shown above. Here are the contents of the batch file:
::DraftFTP.bat
::Uploads Draft Files to Website
@ECHO OFF
cd "C:\Files"
ftp -s:Test.scr
The first two lines are comment lines. The third line tells the batch file not to display the command prompt as the commands are executed. The fourth line changes the directory to where the Test.scr file is located. You should recognize what the fifth line does from what we did above.
Now we have a batch file. Double click it and it will run, placing the two files on to the webserver.
So we’re almost there. Now that we have the ftp script and the batch file to run it, all we need to do is create a scheduled job to automatically run the batch file at a given interval.
Open the Scheduled Tasks (Start > Programs > Accessories > System Tools > Scheduled Tasks) and create a new Scheduled Task. Don’t bother going through the wizard, just right-click and select New > Scheduled Task. Give it a name and then open it up. In the Task tab, select the batch file you just created as the program to run. Then simply fill out the Schedule, Setting, and Security options as desired.
Then sit back and enjoy as the Scheduled Task runs your batch file containing your FTP script, automatically putting your files according to the schedule you have defined.create a scheduled ftp job
As mentioned above, there is usually more than one way to accomplish a task. If you know a better way to create a scheduled ftp job please share your tips below, or let me know if this solution worked for you.
Entry Filed under: Networking, Software, Web
Share This
Leave a Comment
Subscribe to the comments via RSS Feed