Large FTP uploads

An update of our software installation packages involves uploading 42 files with sizes that range from 20-120 MB. Each file must be placed in a different directory on our server. An FTP program like FileZilla is useful for day-to-day file updating, but lacks script operation features. In this case, an update would involve a tedious process of identifying 42 files and 42 destinations. The situation is worse if we need to update programs from one of our secondary offices. Local Internet providers severely limit upload speed — the figure is 122 kB/s at our Colorado office.

One solution is to automate the process (i.e., prepare the update files and then let the computer upload autonomously for several hours). WinSCP is a good freeware utility to help implement automated FTP transfers. It is available at http://winscp.net/eng/index.php.

The documentation for WinSCP is a little convoluted, so I prepared an example based on my experience to help you set things up. To begin, download and install WinSCP. For convenience, put c:\program files\winscp on the path. Alternatively, copy the relatively small executable files to a location that is already on the path. I use a general directory c:\batch.

As an example, suppose you have the files

c:\distfiles\program01.exe
c:\distfiles\program02.exe
c:\distfiles\program03.exe
c:\distfiles\program04.exe
c:\distfiles\program05.exe

that should be copied to the directories

public_html/download/site01
public_html/download/site02
public_html/download/site03
public_html/download/site04
public_html/download/site05

on your server, automatically replacing any existing files with the same names. Suppose your site has the URL mycompany.com. The user name and password for FTP transfers is myuser and mypassword.

1) Use a text editor to create a file FTPUpload.bat in the directory c:\distfiles with the following single-line content:

winscp.exe /console /script=FTPUpload.txt

The batch file runs WinSCP in the console mode and calls up the script for instructions.

2) Create another file in the directory called FTPUpload.txt with the following content :

open ftp://myuser:mypassword@mycompany.com/public_html/download
option confirm off
cd site01
put program01.exe
cd ../site02
put program02.exe
cd ../site03
put program03.exe
cd ../site04
put program04.exe
cd ../site05
put program05.exe
exit

The first line opens a password-protected FTP session and transfers to a convenient directory. The second line ensures that the script will not pause for confirmation when replacing the old files. The subsequent lines migrate to directories and copy the appropriate files. Simply run the batch file and everything happens automatically. WinSCP maintains a console window to show the status of operations.

Note: If you are bothered by world-class hackers breaking into your office, be careful about storing the file FTPUpload.txt with your site password.

For information on our finite-elements programs, please see http://www.fieldp.com/order.html.

Comments are closed.