Execute a .bat file on FTP server.


Does any one know how we can execute a .bat file on a FTP server. We have requirement where after putting few files on FTP server , we have to execute a .bat file.

Is there any way pub.client.ftp:quote service can do this. If Yes what has to be the input of pub.client.ftp:quote service.

The other approach I was thinking is to create a java program on FTP machine which would execute this script and to call java methods through RMI or through a webserivce, but I dont how feasible would be this approach.

Is there any other simple way I can achieve this ?



first of all, it’s a big security hole if you allow your FTP server to launch any execution. It’s why it’s disabled on most FTP server.

If not disabled, you can issue a “SITE” command thru quote service in order to launch the execution. Some other ftpd implement custom command to execute something (i.e. EXEC on HP-UX’s ftpd), but I think it’s far than standard. As consequence, you would have to implement different connectivity choregraphy for each remote server you have.


I’m not a specialist of brain damaged windows environment, but on unix, it’s quite easy to create a shell script that monitor a directory for incomming files (a la file pooling) and then launch another script againts them.

If ms-DOS is not powerfull enought to handle that, you can create simple PERL or PHP scripts to implement this. If you have some performances issue, a C or C++ implementation is very easy to do and is a good option (I personnaly don’t like JAVA for such thing as the overhault to launch JVM engine).

Good luck.



From what you described I understood that after transfering some files to win ftp server you need to invoke some batch file on remote machine to process uploaded files.

In such case you can use some tool on Windows machine to monitor directory for changes (e.g. one that uses FileSystemWatcher class). This deamon will watch for appearance of files with specific extension and call processing batch script. Upload file with temporary name and rename it to desired name after upload is completed.

hth, regards.

Hi Laurent & Holden

Thank a lot for a quick explanation. As now of now we have dropped the plan to execute a batch throught an FTP because of security issues and going for some other alter ways.