Automate the Upload of a File to an FTP Server
This page explains how to automate the upload of a binary file on a Windows client to a UNIX FTP server.Create a bat file on the Windows client with the below contents. Replace 'c:\ftp.txt' with your FTP command file (see below) and 192.168.1.250 with the FTP server's IP address.
ftp -s:c:\ftp.txt 192.168.1.250
Create a text file that contains your FTP commands (c:\ftp.txt). You will need to specify the FTP user password in this file in plain text, so ensure that you lock down the permissions on the file accordingly. The below commands will copy the local file 'c:\mailbox.pst' on the Windows client, to '/home/desintation_dir' on the FTP server.
ftp_username
password
binary
cd /home/destination_dir
put c:\mailbox.pst
bye
To initiate the file upload, run the bat file. You can do this via a scheduled task if you like.
Note, in order to upload the file using the 'put' command, you will need to create an inbound firewall rule on the Windows client allowing remote ports 20 and 21 to access any local port.