07-23-2023, 10:17 AM
I have a somewhat related, but different questions [here][1].
I have a batch script (`*.bat` file) such as this:
@ftp -i -s:"%~f0"&GOTO:EOF
open
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 a ftp site. My question is that, the upload operation can fail from time to time ( the remote ftp is not available, "myfile.zip" is non-existent, upload operation interrupted and whatnot), and when such unfortunate things happen, I want my bat file return 1 ( `exit 1`).
It would be great if my upload wasn't successful, the ftp would throw an exception ( yes, like exception in C++), and I would have a catch-all exception that catches it and then `exit 1`, but I don' think this is available in batch script.
What is the best way to do what I need here?
[1]:
I have a batch script (`*.bat` file) such as this:
@ftp -i -s:"%~f0"&GOTO:EOF
open
[To see links please register here]
myusermypassword
!:--- 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 a ftp site. My question is that, the upload operation can fail from time to time ( the remote ftp is not available, "myfile.zip" is non-existent, upload operation interrupted and whatnot), and when such unfortunate things happen, I want my bat file return 1 ( `exit 1`).
It would be great if my upload wasn't successful, the ftp would throw an exception ( yes, like exception in C++), and I would have a catch-all exception that catches it and then `exit 1`, but I don' think this is available in batch script.
What is the best way to do what I need here?
[1]:
[To see links please register here]