Error code 0 if get doesn't find any file

Advertisement

jr
Guest

Error code 0 if get doesn't find any file

Hello everybody,

I'm new here and I hope I can get a solution for my issue :

I have a script that upload or download a file on a remote computer using WinSCP and SFTP. The file in question has a variable name so I have to use a filter.

I use the following command to download the file on the remote computer :
"get -delete /home/test/*.csv d:\"    

Problem : if no file has been found in /home/test/ using a filter like *, the return code is 0.

The script return an error (code 1) when I use (test.csv doesn't exist):
"get -delete /home/test/test.csv d:\"    

Is it possible to have an error when the directory is empty or no file has been downloaded ?

Thanks for your help,

Julien
  • download_20140429_165837.log (8.05 KB, Private file)

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,226
Location:
Prague, Czechia

Re: Error code 0 if get doesn't find any file

jr wrote:

Problem : if no file has been found in /home/test/ using a filter like *, the return code is 0.

The script return an error (code 1) when I use (test.csv doesn't exist):
"get -delete /home/test/test.csv d:\"    
That's correct.

See https://winscp.net/eng/docs/scriptcommand_get
When specific file name is used, command fails when the file does not exist. When wildcard is used, command succeeds, without doing anything, if the wildcard does not match any file.

Is it possible to have an error when the directory is empty or no file has been downloaded ?
No. You have to check yourself if any file is present, in advance. Or if any file was downloaded, ex post.

Reply with quote

Advertisement

You can post new topics in this forum