Page 1 of 1

FileWatcher - Script for FTP, SFTP, FTPS and FTPES

Posted: Mon Sep 10, 2012 12:40 pm
by DataMystic Support
This document provides all the information you need to send files via FTP, SFTP, FTPS and FTPES when the file is dropped in a folder.

File Watcher detects the completed file being dropped, and then triggers FileZilla, an open source FTP agent.

Please use standard FTP supplied with Windows using a batch file (ftp.bat, called by FileWatcher) and a script (ftp_script.txt)
FileZilla does not support sending files via the command line – it can only open the GUI at a given domain.
WinSCP can also be used for SFTP, FTPS and FTPES, but it will require slightly different scripting.

Step 1. Save the following file as ftp.bat, and record the path.

ftp.bat

Code: Select all

@echo off
Echo Running FTP
ftp -i -n -s:ftp_script.txt hostname
echo Now delete or move local files so they can't be transferred again
pause

Step 2. In the same location as ftp.bat, create a script command file for FTP - this logs in and transfers your file:

ftp_script.txt:

Code: Select all

username
password
lcd <your local folder>
cd <your remote folder>
mput *.*
quit

Step 3. In FileWatcher, set the Action to ftp.bat, using the complete path from Step 1. The parameters are irrelevant, as standard FTP can't be told exactly which files to transfer (you could try a commercial client). Since all files must be transferred, you must delete them or move them out of the way after FTP to prevent them being processed on the next run.


For FTP command line reference:

Code: Select all

  -i              Turns off interactive prompting during multiple file
                  transfers.
  -s:filename     Specifies a text file containing FTP commands; the
                  commands will automatically run after FTP starts.
  host            Specifies the host name or IP address of the remote
                  host to connect to.