• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 525
  • Last Modified:

FTP batch processing and return code

My application needs to upload files on a remote server. I think FTP is the best way to do that and I'm writing the FTP batch (running on Windows 2000).

The basic scripting is ok (connexion and put command) but I cannot figure out how to know whether the command has been completed or not.

In fact my application need to upload a specific file to the remote host and DELETE it locally if the FTP was done correctly. If FTP failed, the local file should NOT be deleted and it will be uploaded in a fruther attempt.

What could I use in order to get the result (return code) of my FTP command (I'm using FTP -s:script.ftp)?
Thank you in advance for your help.
J. Zimmerli
2 Solutions
I think you can redirect the output from the console to a file and after that check if in the content of the file a certain string presents.
Try adding this to the end of the command..

>>c:\test.txt (this would place a log file in c: named test.txt)  It would look like this...

FTP -s:script.ftp >> c:\test.txt
joel011197Author Commented:
Both suggestions were ok but a little bit to complicated to implement. Furthermore, I need to get different error level if 1) login failed or 2) file upload failed.
So I installed easyphp on my box and the different ftp functions are exactely doing what I need.
Thank you for your help.

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now