Automating FTP on the cheap

All windows 2000 and above computers come with quite a decent selection of tools for automating processes. It is quite trivial for example to backup or copy date to a remote computer using ftp with the exisitng command line tools. By writing your ftp commands to a file and reading this using ftp you can remove the need for human intervention completely.

An example script follows,

Upload file,

@echo off
echo open server > %TEMP%\ftpscript
echo user username password >> %TEMP%\ftpscript
echo bin >> %TEMP%\ftpscript
echo put test1_binary.zip >> %TEMP%\ftpscript
echo put test2_binary.zip >> %TEMP%\ftpscript
echo put test3_binary.zip >> %TEMP%\ftpscript
echo put stock_check.zip >> %TEMP%\ftpscript
echo bye >> %TEMP%\ftpscript
echo. >> %TEMP%\ftpscript
ftp -n -i < %TEMP%\ftpscript

This is a very simple script that creates the script it uses on the fly. Use the scheduler (accessable via the computer settings option) to add the script to it and you have an automated file copy.

Note: one of the things you need to be careful about is who has permission to the scripts and temp files. The script must have the username and password in it.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s