I have a few related but different questions here .
I have a batch script ( *.bat) file , for example:
@ftp -i -s:"%~f0"&GOTO:EOF
open ftp.myhost.com
myuser
mypassword
!:--- FTP commands below here ---
lcd "C:\myfolder"
cd /testdir
binary
put "myfile.zip"
disconnect
bye
Basically this is a script that uploads a zip file to an ftp site. My question is that the download operation may fail from time to time (remote ftp is not available, "myfile.zip" does not exist, the download operation is aborted and much more), and when such unsuccessful things happen, I want my bat file return 1 ( exit 1).
It would be great if my download were not successful, ftp would throw an exception (yes, like an exception in C ++), and I would have a catch-all exception that catches it, and then exit 1, but I don’t think that it is available in the script package.
What is the best way to do what I need here?
source
share