Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Checking for error when using get and * and file not present

The behaviour is as designed.

This example may help you.
a052775

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

Using version WinSCP Version 4.2.7 (Build 758) (OS 6.0.6001 Service Pack 1)
Overview:
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?

Testing:
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>winscp.com 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...
Authenticating...
Using username "ACME".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] StuffTEST
batch           on
confirm         off
\\fiddat\data\zztest
/outbox

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

C:\Program Files\WinSCP>

LOGS:
. 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
\\fiddat\data\zztest
/outbox
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%
1