Linker IT Software
menubar-top-links menubar-top-rechts
Home Help Search Login
Welcome, Guest. Please Login.
SQL*XL: Database to Excel bridge litLIB: Excel power functions pack ExcelLock: Locking and securing your valuable Excel spreadsheets encOffice: Protect your Excel file easy and safe encOffice: Protect your Excel file easy and safe
Pages: 1
Automating FTP transfers with batch file (Read 5241 times)
Gerrit-Jan Linker
YaBB Administrator

Posts: 75
Automating FTP transfers with batch file
06.04.06 at 10:00:06
I frequently download or upload files using FTP. When I release new software I need to upload a new binary file and I frequently backup sections of the site - the forums for example. The backup needs to be run automatically every day so it is convenient to have a batch file that is started at boot-up.
To start, make two new text files in the same directory. Name the first file job.bat and name the second file commands.txt.
Open job.bat in notepad and type the following lines:
ping -n 1 -w 5000 >NUL
ftp -s:command.txt

The ping command will pause the batch file 5 seconds. Just to ensure a network connection will be in place when the batch file is started at bootup.  
The ftp command connects to the site and uses the command file command.txt
Open the command.txt file in notepad and type the following lines:
cd mydir
lcd c:\mydir
mget *

user and pass are the username and password to connect through FTP
You can use cd to change directory to the directory where you want to upload or download
You use the lcd command to change the directory on your local PC.
ascii sets the transfer mode to text mode. Use the binary command to set the transfer mode for binary files
prompt sets the interactive mode on or off. I will be getting multiple files and I do not want to be prompted for every file.
mget will get all the files specified. Use get to get one file. Use mput to put multiple files and use put to get one file.
bye will close ftp and will return to the batch file.
To automatically run the batch file at startup you need to put a shortcut to the batch file in your Start | Programs | Startup folder.
Back to top

Gerrit-Jan Linker
Linker IT Software
Email WWW Gerrit-Jan Linker   IP Logged
Pages: 1