Topic "Checking for error when using get and * and file not present"

Author Message
[View user's profile]

Joined: 2010-04-01
Posts: 3
Location: DFW
Using version WinSCP Version 4.2.7 (Build 758) (OS 6.0.6001 Service Pack 1)
From scripting command when I use get and a specific file name and its not their I get an "errorlevel 1" as expected. When I use get with fileName* using * at the end of the file and no files are present I get "errorlevel 0" when I think I should get a "errorlevel 0". When I enable logging on the get with * it shows a "Status code: 1". Is there a way I can use get with * and have a return of 1 if no files are present?

Checking for error when using get and file not present
When I use GET SpecificFile and the file is not preset I get an error return code which is what I would expect.
When I use GET SpecificFile* with the * wildcard and no file is present then I get a return of 0 even though in the log I see a Status code: 1.

C:\Program Files>cd WinSCP

C:\Program Files\WinSCP> StuffTEST /command "option batch on" "option confirm off" "LCD \\fiddat\data\sbtest"
"cd outbox" "GET ZZZ004.777.R#428826*" "bye" "close" /ini="C:\Program Files\WinSCP\WinSCP.ini"
Searching for host...
Connecting to host...
Using username "ACME".
Authenticating with pre-entered password.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] StuffTEST
batch on
confirm off

C:\Program Files\WinSCP>echo %errorlevel%

C:\Program Files\WinSCP>

. 2010-04-29 09:45:31.611 WinSCP Version 4.2.7 (Build 758) (OS 6.0.6001 Service Pack 1)
. 2010-04-29 09:45:31.611 Login time: Thursday, April 29, 2010 9:45:31 AM
. 2010-04-29 09:45:31.627 --------------------------------------------------------------

> 2010-04-29 09:46:51.640 Type: SSH_FXP_OPENDIR, Size: 16, Number: 267
< 2010-04-29 09:46:51.703 Type: SSH_FXP_HANDLE, Size: 10, Number: 267
> 2010-04-29 09:46:51.703 Type: SSH_FXP_READDIR, Size: 10, Number: 524
< 2010-04-29 09:46:51.734 Type: SSH_FXP_NAME, Size: 1755, Number: 524
> 2010-04-29 09:46:51.734 Type: SSH_FXP_READDIR, Size: 10, Number: 780
< 2010-04-29 09:46:51.765 Type: SSH_FXP_STATUS, Size: 17, Number: 780
< 2010-04-29 09:46:51.765 Status code: 1
> 2010-04-29 09:46:51.765 Type: SSH_FXP_CLOSE, Size: 10, Number: 1028
. 2010-04-29 09:46:51.765 Closing connection.
. 2010-04-29 09:46:51.765 Sending special code: 12
. 2010-04-29 09:46:51.765 Sent EOF message

Same command without the * in the get file name.

batch on
confirm off
Can't get attributes of file 'ZZZ004.777.R#428826.
No such file or directory.
Error code: 2
Error message from server: /outbox/ GET ZZZ004.777.R#428826 is not a valid file path
Request code: 7

C:\Program Files\WinSCP>echo %errorlevel%
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26858
Location: Prague, Czechia
The behaviour is as designed.

This example may help you.
Martin Prikryl

You can post new topics in this forum


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!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License