Topic "Error code 0 if get doesn't find any file"

Author Message
jr

Guest


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 :
Code:
"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):
Code:
"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

Description: (none)

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24995
Location: Prague, Czechia
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):
Code:
"get -delete /home/test/test.csv d:\"

That's correct.

See https://winscp.net/eng/docs/scriptcommand_get
Quote:
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.


Quote:
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.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License