Status Code: 0 on Get's?

Advertisement

JimGriffith
Joined:
Posts:
18

Status Code: 0 on Get's?

Why is it that we don't get a status code 0 on Gets commands? It seems like we used to. Here's a log from some testing where the file was transfered successfully but no "0"
. 2011-01-11 10:21:52.192 --------------------------------------------------------------------------
. 2011-01-11 10:21:52.192 WinSCP Version 4.2.9 (Build 938) (OS 6.1.7600)
. 2011-01-11 10:21:52.192 Login time: Tuesday, January 11, 2011 10:21:52 AM
. 2011-01-11 10:21:52.192 --------------------------------------------------------------------------
. 2011-01-11 10:21:52.192 Session name: User_Name@ftpserver.com
. 2011-01-11 10:21:52.192 Host name: ftpserver.com (Port: 22)
. 2011-01-11 10:21:52.192 User name: User_Name (Password: Yes, Key file: No)
. 2011-01-11 10:21:52.192 Tunnel: No
. 2011-01-11 10:21:52.193 Transfer Protocol: SFTP
. 2011-01-11 10:21:52.193 Ping type: -, Ping interval: 30 sec; Timeout: 15 sec
. 2011-01-11 10:21:52.193 Proxy: none
. 2011-01-11 10:21:52.193 SSH protocol version: 2; Compression: No
. 2011-01-11 10:21:52.193 Bypass authentication: No
. 2011-01-11 10:21:52.193 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No
. 2011-01-11 10:21:52.193 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2011-01-11 10:21:52.193 SSH Bugs: -,-,-,-,-,-,-,-,-
. 2011-01-11 10:21:52.193 SFTP Bugs: -,-
. 2011-01-11 10:21:52.193 Return code variable: Autodetect; Lookup user groups: Yes
. 2011-01-11 10:21:52.193 Shell: default
. 2011-01-11 10:21:52.193 EOL: 0, UTF: 2
. 2011-01-11 10:21:52.193 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
. 2011-01-11 10:21:52.193 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
. 2011-01-11 10:21:52.193 Local directory: default, Remote directory: home, Update: No, Cache: Yes
. 2011-01-11 10:21:52.193 Cache directory changes: Yes, Permanent: Yes
. 2011-01-11 10:21:52.193 DST mode: 1
. 2011-01-11 10:21:52.193 --------------------------------------------------------------------------
. 2011-01-11 10:21:52.216 Looking up host "ftpserver.com"
. 2011-01-11 10:21:52.286 Connecting to 000.000.000.000 port 22
. 2011-01-11 10:21:52.459 Server version: SSH-2.0-WingFTPserver
. 2011-01-11 10:21:52.459 We believe remote version has SSH-2 ignore bug
. 2011-01-11 10:21:52.459 Using SSH protocol version 2
. 2011-01-11 10:21:52.459 We claim version: SSH-2.0-WinSCP_release_4.2.9
. 2011-01-11 10:21:52.504 Doing Diffie-Hellman group exchange
. 2011-01-11 10:21:52.798 Doing Diffie-Hellman key exchange with hash SHA-1
. 2011-01-11 10:21:52.877 Host key fingerprint is:
. 2011-01-11 10:21:52.877 ssh-rsa 1024 fc:92:54:e6:06:04:1a:97:8c:8c:cb:a7:72:e0:86:52
. 2011-01-11 10:21:52.877 Initialised Blowfish-128 CBC client->server encryption
. 2011-01-11 10:21:52.877 Initialised HMAC-SHA1 client->server MAC algorithm
. 2011-01-11 10:21:52.877 Initialised Blowfish-128 CBC server->client encryption
. 2011-01-11 10:21:52.877 Initialised HMAC-SHA1 server->client MAC algorithm
! 2011-01-11 10:21:53.185 Using username "User_Name".
. 2011-01-11 10:21:53.279 Prompt (6, SSH password, , &Password: )
. 2011-01-11 10:21:53.279 Using stored password.
. 2011-01-11 10:21:53.280 Sent password
. 2011-01-11 10:21:53.328 Access granted
. 2011-01-11 10:21:53.372 Opened channel for session
. 2011-01-11 10:21:53.662 Started a shell/command
. 2011-01-11 10:21:53.662 --------------------------------------------------------------------------
. 2011-01-11 10:21:53.662 Using SFTP protocol.
. 2011-01-11 10:21:53.662 Doing startup conversation with host.
> 2011-01-11 10:21:53.673 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2011-01-11 10:21:53.722 Type: SSH_FXP_VERSION, Size: 5, Number: -1
. 2011-01-11 10:21:53.722 SFTP version 3 negotiated.
. 2011-01-11 10:21:53.722 We believe the server has signed timestamps bug
. 2011-01-11 10:21:53.722 We will use UTF-8 strings for status messages only
. 2011-01-11 10:21:53.722 Getting current directory name.
. 2011-01-11 10:21:53.722 Getting real path for '.'
> 2011-01-11 10:21:53.723 Type: SSH_FXP_REALPATH, Size: 10, Number: 16
< 2011-01-11 10:21:53.770 Type: SSH_FXP_NAME, Size: 23, Number: 16
. 2011-01-11 10:21:53.770 Real path is '/'
. 2011-01-11 10:21:53.770 Startup conversation with host finished.
< 2011-01-11 10:21:53.771 Script: Active session: [1] User_Name@ftpserver.com
> 2011-01-11 10:21:53.771 Script: option confirm off 
< 2011-01-11 10:21:53.771 Script: confirm         off       
> 2011-01-11 10:21:53.771 Script: option transfer binary 
< 2011-01-11 10:21:53.771 Script: transfer        binary    
> 2011-01-11 10:21:53.771 Script: get get_testing.txt
. 2011-01-11 10:21:53.771 Listing file "get_testing.txt".
> 2011-01-11 10:21:53.771 Type: SSH_FXP_LSTAT, Size: 25, Number: 263
< 2011-01-11 10:21:53.822 Type: SSH_FXP_ATTRS, Size: 37, Number: 263
. 2011-01-11 10:21:53.828 File: "/get_testing.txt"
. 2011-01-11 10:21:53.828 Copying "/get_testing.txt" to local directory started.
. 2011-01-11 10:21:53.828 Binary transfer mode selected.
. 2011-01-11 10:21:53.854 Opening remote file.
> 2011-01-11 10:21:53.854 Type: SSH_FXP_OPEN, Size: 33, Number: 515
< 2011-01-11 10:21:53.912 Type: SSH_FXP_HANDLE, Size: 27, Number: 515
> 2011-01-11 10:21:53.912 Type: SSH_FXP_FSTAT, Size: 27, Number: 776
> 2011-01-11 10:21:53.912 Type: SSH_FXP_READ, Size: 39, Number: 1029
. 2011-01-11 10:21:53.972 Storing reserved response
< 2011-01-11 10:21:54.077 Status code: 1
. 2011-01-11 10:21:54.077 4 skipped SSH_FXP_WRITE, SSH_FXP_READ, SSH_FXP_DATA and SSH_FXP_STATUS packets.
> 2011-01-11 10:21:54.077 Type: SSH_FXP_CLOSE, Size: 27, Number: 1540
> 2011-01-11 10:21:54.084 Script: exit 
. 2011-01-11 10:21:54.084 Closing connection.
. 2011-01-11 10:21:54.084 Sending special code: 12
. 2011-01-11 10:21:54.084 Sent EOF message

Reply with quote E-mail

Advertisement

JimGriffith

So from an automation stand point, what piece of information can I have my application search for to determine that the file was transferred successfully? The put transfers all return a status code: 0 when it is successful, why doesn't the get?

Reply with quote E-mail

JimGriffith
Joined:
Posts:
18

Okay maybe I'm just not getting something here..and I apologize for I guess being an idiot.

Here's the XML from a run.
<?xml version="1.0" encoding="UTF-8"?>
<session xmlns="https://winscp.net/schema/session/1.0" name="UC4" start="2011-01-21T15:41:02.959Z">
  <download>
    <filename value="/get_testing1.txt" />
    <destination value="C:\Users\me\Desktop\get_testing1.txt" />
    <result success="true" />
  </download>
</session>
To me this looks good.... <result success="true" />

However, when I then change the logging to txt and use the same session and get the same file (after I've deleted the file on my local machine) the txt log shows a status code of 1.

So why am I still getting a status code of 1 when the XML shows a success?

I've also run this 2 more times using the debug level 1 & 2 of logging and I don't see an error in either one, but then again I might just not know what I'm looking for.

Reply with quote E-mail

Advertisement

martin
Site Admin
martin avatar

I'm sorry, but I'm not going to teach you SFTP protocol specification. If you are curious read it yourself :) As a user, you do not need to bother about the SFTP status codes.

Also I do not understand your point about the error. Why do you expect to see any errors in the logs?

Reply with quote

JimGriffith
Joined:
Posts:
18

I guess I expect to see an error because of this statement...

Checking Results
WinSCP returns exit code 1, when any command is interrupted due to an error or any prompt is answered Abort (even automatically in batch mode). Otherwise it returns the exit code 0. To further analyze results of scripted operations, you will find XML logging useful.

To me that says that an exit code of 1 will be shown in the log when there's an error or when you've select "abort" on a prompt. Otherwise on a fully successful transmission, the exit code will be 0.

Essentially all I'm looking for is a way to tell my automated process that this transmission was successful. Like..
Status code: 0
Transfer Successful

Even the integrated FTP in Windows says "Transfer complete" in its logs.

I do appreciate any help you can provide on this.

Reply with quote E-mail

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

JimGriffith wrote:

Checking Results
WinSCP returns exit code 1, when any command is interrupted due to an error or any prompt is answered Abort (even automatically in batch mode). Otherwise it returns the exit code 0. To further analyze results of scripted operations, you will find XML logging useful.
That's correct. But application exit code cannot be logged into its log file. Simply because the log file is already closed by the time application exits. And exit code is not SFTP status code.

Reply with quote

martin
Site Admin
martin avatar

Recent versions of WinSCP log WinSCP exit code in scripting. At least the exit code WinSCP believes it will return at the moment it is closing the log file. In extreme cases it might change afterwards.

Reply with quote

Advertisement

You can post new topics in this forum