Topic "Console Script Report No Error Yet .NET Apps Do Report Error"

Author Message
UpsideDownTire
[View user's profile]

Joined: 2009-07-29
Posts: 3
My problem is my applications are telling me an error happened. The console execution of the original script does not report an error. So I am very confused as to whom to believe. In every case, my downloaded test file is just fine. It more than 7 MB in size.

I first tested the script in console then copied it to VS 2008 in both VB.NET and C#.

The script and the .NET applications are based upon your samples in the .NET Guide. Both apps suggest the exit code is one (an error ocurred). The script run in console does not report an error.

In all logs, from apps and console, I see a line with "Status/error code: 1". I am assuming that means an error happened. Is this a correct assumption, an error did occurr? If so, how do I find out the error?

WinSCP


    4.1.9 (Build 416)


Workstation OS


    Vista Business (SP2)
    Windows 2003 Server (SP2)


Here's my script:

    option batch abort
    option confirm off
    open sftp://userName:passWord@ftp.site.com:22 -hostkey="ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" -timeout=180
    cd /datafiles
    option transfer binary
    get -preservetime BigMotherOfAnXMLFile.xml D:\site\datafiles\test\BigMotherOfAnXMLFile.xml
    close
    exit


Here's my log from Windows 2003 Server:

    . 2009-07-29 15:32:57.171 --------------------------------------------------------------------------
    . 2009-07-29 15:32:57.171 WinSCP Version 4.1.9 (Build 416) (OS 5.2.3790 Service Pack 2)
    . 2009-07-29 15:32:57.171 Login time: Wednesday, July 29, 2009 3:32:57 PM
    . 2009-07-29 15:32:57.171 --------------------------------------------------------------------------
    . 2009-07-29 15:32:57.171 Session name: userName@ftp.site.com
    . 2009-07-29 15:32:57.171 Host name: ftp.site.com (Port: 22)
    . 2009-07-29 15:32:57.171 User name: userName (Password: Yes, Key file: No)
    . 2009-07-29 15:32:57.171 Tunnel: No
    . 2009-07-29 15:32:57.171 Transfer Protocol: SFTP
    . 2009-07-29 15:32:57.171 Ping type: -, Ping interval: 30 sec; Timeout: 180 sec
    . 2009-07-29 15:32:57.171 Proxy: none
    . 2009-07-29 15:32:57.171 SSH protocol version: 2; Compression: No
    . 2009-07-29 15:32:57.171 Bypass authentication: No
    . 2009-07-29 15:32:57.171 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No
    . 2009-07-29 15:32:57.171 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
    . 2009-07-29 15:32:57.171 SSH Bugs: -,-,-,-,-,-,-,-
    . 2009-07-29 15:32:57.171 SFTP Bugs: -,-
    . 2009-07-29 15:32:57.171 Return code variable: Autodetect; Lookup user groups: Yes
    . 2009-07-29 15:32:57.171 Shell: default, EOL: 0
    . 2009-07-29 15:32:57.171 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
    . 2009-07-29 15:32:57.171 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
    . 2009-07-29 15:32:57.171 Local directory: default, Remote directory: home, Update: No, Cache: Yes
    . 2009-07-29 15:32:57.171 Cache directory changes: Yes, Permanent: Yes
    . 2009-07-29 15:32:57.171 DST mode: 1
    . 2009-07-29 15:32:57.171 --------------------------------------------------------------------------
    . 2009-07-29 15:32:57.171 Looking up host "ftp.site.com"
    . 2009-07-29 15:32:57.187 Connecting to 000.000.000.000 port 22
    . 2009-07-29 15:32:57.265 Server version: SSH-2.0-OpenSSH_5.2
    . 2009-07-29 15:32:57.265 We claim version: SSH-2.0-WinSCP_release_4.1.9
    . 2009-07-29 15:32:57.265 SSPI: acquired credentials for: Administrator@Win2k3Svr
    . 2009-07-29 15:32:57.265 Constructed service principal name 'host/ftp.site.com'
    . 2009-07-29 15:32:57.265 GSSKEX disabled: No credentials are available in the security package

    . 2009-07-29 15:32:57.265 Using SSH protocol version 2
    . 2009-07-29 15:32:57.296 Doing Diffie-Hellman group exchange
    . 2009-07-29 15:32:57.406 Doing Diffie-Hellman key exchange with hash SHA-1
    . 2009-07-29 15:32:57.640 Host key fingerprint is:
    . 2009-07-29 15:32:57.640 ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
    . 2009-07-29 15:32:57.640 Initialised AES-256 SDCTR client->server encryption
    . 2009-07-29 15:32:57.640 Initialised HMAC-SHA1 client->server MAC algorithm
    . 2009-07-29 15:32:57.640 Initialised AES-256 SDCTR server->client encryption
    . 2009-07-29 15:32:57.640 Initialised HMAC-SHA1 server->client MAC algorithm
    ! 2009-07-29 15:32:57.718 Using username "userName".
    . 2009-07-29 15:32:57.828 Prompt (5, SSH server authentication, Using keyboard-interactive authentication., Password: )
    . 2009-07-29 15:32:57.828 Using stored password.
    . 2009-07-29 15:32:57.890 Access granted
    . 2009-07-29 15:32:57.937 Opened channel for session
    . 2009-07-29 15:32:57.968 Started a shell/command
    . 2009-07-29 15:32:57.968 --------------------------------------------------------------------------
    . 2009-07-29 15:32:57.968 Using SFTP protocol.
    . 2009-07-29 15:32:57.968 Doing startup conversation with host.
    > 2009-07-29 15:32:57.968 Type: SSH_FXP_INIT, Size: 5, Number: -1
    < 2009-07-29 15:32:58.109 Type: SSH_FXP_VERSION, Size: 95, Number: -1
    . 2009-07-29 15:32:58.109 SFTP version 3 negotiated.
    . 2009-07-29 15:32:58.109 Unknown server extension posix-rename@openssh.com=1
    . 2009-07-29 15:32:58.109 Unknown server extension statvfs@openssh.com=2
    . 2009-07-29 15:32:58.109 Unknown server extension fstatvfs@openssh.com=2
    . 2009-07-29 15:32:58.109 We believe the server has signed timestamps bug
    . 2009-07-29 15:32:58.109 We will use UTF-8 strings for status messages only
    . 2009-07-29 15:32:58.109 Limiting packet size to OpenSSH sftp-server limit of 262148 bytes
    . 2009-07-29 15:32:58.109 Getting current directory name.
    . 2009-07-29 15:32:58.109 Getting real path for '.'
    > 2009-07-29 15:32:58.109 Type: SSH_FXP_REALPATH, Size: 10, Number: 16
    < 2009-07-29 15:32:58.187 Type: SSH_FXP_NAME, Size: 23, Number: 16
    . 2009-07-29 15:32:58.187 Real path is '/'
    . 2009-07-29 15:32:58.187 Startup conversation with host finished.
    . 2009-07-29 15:32:58.187 Cached directory change via "/datafiles" to "/datafiles".
    . 2009-07-29 15:32:58.187 Getting current directory name.
    . 2009-07-29 15:32:58.187 Listing file "BigMotherOfAnXMLFile.xml".
    > 2009-07-29 15:32:58.187 Type: SSH_FXP_LSTAT, Size: 81, Number: 263
    < 2009-07-29 15:32:58.218 Type: SSH_FXP_ATTRS, Size: 37, Number: 263
    . 2009-07-29 15:32:58.218 File: "/datafiles/BigMotherOfAnXMLFile.xml"
    . 2009-07-29 15:32:58.218 Copying "/datafiles/BigMotherOfAnXMLFile.xml" to local directory started.
    . 2009-07-29 15:32:58.218 Binary transfer mode selected.
    . 2009-07-29 15:32:58.218 Checking existence of partially transfered file.
    . 2009-07-29 15:32:58.218 Opening remote file.
    > 2009-07-29 15:32:58.218 Type: SSH_FXP_OPEN, Size: 89, Number: 515
    < 2009-07-29 15:32:58.265 Type: SSH_FXP_HANDLE, Size: 13, Number: 515
    > 2009-07-29 15:32:58.265 Type: SSH_FXP_FSTAT, Size: 13, Number: 776
    > 2009-07-29 15:32:58.265 Type: SSH_FXP_READ, Size: 25, Number: 1029
    . 2009-07-29 15:32:58.296 3 skipped SSH_FXP_WRITE, SSH_FXP_READ, SSH_FXP_DATA and SSH_FXP_STATUS packets.
    < 2009-07-29 15:32:58.296 Type: SSH_FXP_ATTRS, Size: 37, Number: 776
    . 2009-07-29 15:32:58.296 Storing reserved response
    < 2009-07-29 15:33:14.390 Status/error code: 1
    . 2009-07-29 15:33:14.390 493 skipped SSH_FXP_WRITE, SSH_FXP_READ, SSH_FXP_DATA and SSH_FXP_STATUS packets.
    > 2009-07-29 15:33:14.390 Type: SSH_FXP_CLOSE, Size: 13, Number: 65028
    < 2009-07-29 15:33:14.390 Type: SSH_FXP_STATUS, Size: 28, Number: 64261
    < 2009-07-29 15:33:14.484 Type: SSH_FXP_STATUS, Size: 28, Number: 64517
    < 2009-07-29 15:33:14.484 Type: SSH_FXP_STATUS, Size: 28, Number: 64773
    . 2009-07-29 15:33:14.484 Closing connection.
    . 2009-07-29 15:33:14.484 Sending special code: 12
    . 2009-07-29 15:33:14.484 Sent EOF message


I can provide the source code to my C# app if you would like. I'll have to do that by separate post. Just let me know.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24553
Location: Prague, Czechia
UpsideDownTire wrote:
My problem is my applications are telling me an error happened.

How does your application decide that error happens?

Quote:
In all logs, from apps and console, I see a line with "Status/error code: 1". I am assuming that means an error happened. Is this a correct assumption, an error did occurr? If so, how do I find out the error?

That's wrong assumption.

Please read FAQ. If that does not help, come back.
_________________
Martin Prikryl
UpsideDownTire
[View user's profile]

Joined: 2009-07-29
Posts: 3
prikryl wrote:
UpsideDownTire wrote:
My problem is my applications are telling me an error happened.

How does your application decide that error happens?

Quote:
In all logs, from apps and console, I see a line with "Status/error code: 1". I am assuming that means an error happened. Is this a correct assumption, an error did occurr? If so, how do I find out the error?

That's wrong assumption.

Please read FAQ. If that does not help, come back.


I am very aware of that reference.

My application decides that an error has happened through the use of your examples from your guide here.

Here's a snip of my code:

Code:


Dim processWinSCP As Process = New Process()

Dim logname As String

logname = "C:\log.txt"

' Build the Process
processWinSCP.StartInfo.FileName = "C:\Program Files\WinSCP\WinSCP.com"
processWinSCP.StartInfo.Arguments = "/log=" + logname
processWinSCP.StartInfo.UseShellExecute = False
processWinSCP.StartInfo.RedirectStandardInput = True
processWinSCP.StartInfo.RedirectStandardOutput = True
processWinSCP.StartInfo.CreateNoWindow = True
processWinSCP.Start()

' Feed in the scripting commands
processWinSCP.StandardInput.WriteLine("option batch abort")
processWinSCP.StandardInput.WriteLine("option confirm off")
processWinSCP.StandardInput.WriteLine("open sftp://userName:passWord@ftp-site.com:22 -hostkey=""ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"" -timeout=180 ")
processWinSCP.StandardInput.WriteLine("cd /datafiles")
processWinSCP.StandardInput.WriteLine("option transfer binary")
processWinSCP.StandardInput.WriteLine("get -preservetime BigMotherOfAnXMLFile.xml C:\BigMotherOfAnXMLFile.xml ")
processWinSCP.StandardInput.WriteLine("close")

' Collect all output (not used in this example)
Dim output As String = processWinSCP.StandardOutput.ReadToEnd()

Debug.Print(output)

' Wait until WinSCP finishes
processWinSCP.WaitForExit()


' Success (0) or error?
If processWinSCP.ExitCode <> 0 Then

        Console.WriteLine("Error occured")

End If




How does one determine the specific cause for a failure when the ExitCode is one? The only resource is to visually examine the log?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24553
Location: Prague, Czechia
UpsideDownTire wrote:
How does one determine the specific cause for a failure when the ExitCode is one? The only resource is to visually examine the log?

Log file contains only errors specific to session. You may have some script level error as well, such as unrecognised command. Such error can be seen in the output only (processWinSCP.StandardOutput.ReadToEnd). Post the output if you need a help.
_________________
Martin Prikryl
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