Re: Even with option batch continue still exits with error code
@rtanenbaum: See https://winscp.net/eng/docs/script_checking_file_existence#scripting
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
option batch continue does:
get noneexisting.txt
Can't get attributes of file 'noneexisting.txt'.
No such file or directory.
Error code: 2
Error message from server (en): The file does not exist.
get existing.txt
existing.txt | 3 B | 0,0 KB/s | binary | 100%
batch option that would allow the multiple gets to be processed even if the file name is fully specified (no wildcards). The option batch on and option batch continue do not cause it to continue after failing to find a file. The only way I was able to allow it to continue even if the file is not found, is to put a wildcard in the file name even if it is not needed. This worked for me, but does not feel like a clean approach. Being able to have a value for the batch option or a flag on the get command to convey the meaning of "if the file is not found just proceed like there was no error" would satisfy this need.
option batch on
exit at the end.
get and mget both can use wildcards.
get in a single session. But with WinSCP failing and stopping on the first file it can’t find the other get do not execute. I had to break our one native FTP session of three get into three separate WinSCP sessions.
get with a specific file name and the file is not there WinSCP throws an error and just quits. If there other command for the session they are not executed. And the exit command at the end is not executed.
get with a wildcard and there is no file it continues on to the next command including the exit at the end.
get on a specific file name is not found don’t end the session, go to the next command … like a get with a wildcard does.
get with a wildcards. There are no files to pull but the session goes to the second get and finally executes the exit:
cd DON_TAYLOR_TEST
/home/ftp/DON_TAYLOR_TEST
get * C:\tmp\WinSCP_test\get_data_here\
No file matching '*' found.
get * C:\tmp\WinSCP_test\get_data_here\
No file matching '*' found.
exit
C:\tmp\
get for a specific files name. The first get finds no files. The session ends and does not execute the second get or the exit:
cd DON_TAYLOR_TEST
/home/ftp/DON_TAYLOR_TEST
get don_test-1.txt C:\tmp\WinSCP_test\get_data_here\
Can't get attributes of file 'don_test-1.txt'.
No such file or directory.
Error code: 2
Error message from server: No such file
C:\tmp\
mget in WinSCP. It's just an alias for get. They behave the same.
get fails when there is no file and doesn’t continue to the exit command. I’m using command lines. (code listed below the examples). If I use a mget with an * in the file name it does end cleanly.
get:
F:\ecs>"C:\Program Files (x86)\WinSCP\WinSCP.com" /ini=nul /script="F:\ecs\z-GXS_test.txt"
echo on
open sftp:// ******:***@FTP.xxx.com/ -hostkey="ssh-rsa 1024 4Q18VXXv3xw0xCrhpJVtIhqANlUrOf924HYGORyq0LI=" -timeout=300 -rawsettings CacheDirectories=0 CacheDirectoryChanges=0 EOLType=1
Searching for host...
Connecting to host...
Authenticating...
Using username "******".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Session started.
Active session: [1] ******@FTP.xxx.com
cd from_cass
/from_cass
get MDBDATAAA.TXT f:\edi\ediprd\xlate\mbx\ck02521\recv\don_cassmthly.txt
Can't get attributes of file 'MDBDATAAA.TXT'.
No such file or directory.
Error code: 2
Error message from server (en): No such file.
F:\ecs>
mget:
mget and is doesn’t fail when there is no file. It executes the exit at the end.
F:\ecs>"C:\Program Files (x86)\WinSCP\WinSCP.com" /ini=nul /script="F:\ecs\z-GXS_test.txt"
echo on
open sftp://******:***@FTP.cassinfo.com/ -hostkey="ssh-rsa 1024 4Q18VXXv3xw0xCrhpJVtIhqANlUrOf924HYGORyq0LI=" -timeout=300 -rawsettings CacheDirectories=0 CacheDirectoryChanges=0 EOLType=1
Searching for host...
Connecting to host...
Authenticating...
Using username "******".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Session started.
Active session: [1] ******@FTP.xxx.com
cd from_cass
/from_cass
mget MDBDATAAA.TXT* f:\edi\ediprd\xlate\mbx\ck02521\recv\don_cassmthly.txt
No file matching 'MDBDATAAA.TXT*' found.
exit
F:\ecs>
z-GXS_sFTP_test.bat:
echo on
"C:\Program Files (x86)\WinSCP\WinSCP.com" /ini=nul /script="F:\ecs\z-GXS_test.txt"
z-GXS_test.txt:
get:
option echo on
open sftp://cs011900:xxxxxx@FTP.xxxxxx.com/ -hostkey="ssh-rsa 1024 4Q18VXXv3xw0xCrhpJVtIhqANlUrOf924HYGORyq0LI=" -timeout=300 -rawsettings CacheDirectories=0 CacheDirectoryChanges=0 EOLType=1
cd from_cass
get MDBDATAAA.TXT f:\edi\ediprd\xlate\mbx\ck02521\recv\don_cassmthly.txt
exit
mget: