Topic "4.3.6 returns error code 1 and 0 bytes transferred"

Author Message
Craig Brennan
[View user's profile]

Joined: 2012-01-23
Posts: 2
I just updated to 4.3.6 from 4.3.5
I use scripting and have had no problems going back 4 or 5 versions.
Using Windows 7 Ultimate, SFTP-4 and scripting to MS Server 2008 Std.
I use 2 methods, command line script and sessions.
Sessions returns error code 1, 0 bytes transferred.
Command line returns error code 0, 0 bytes transferred.
Both acutally transfer fine.
This only applies to uploads.
Downloads work fine.

Here arethe code and logs for both methods:

Session protocol = SSH-2
SSH implementation = 1.00 FlowSsh: WinSSHD 5.05
Encryption algorithm = aes
Compression = No
File transfer protocol = SFTP-4
------------------------------------------------------------
Server host key fingerprint
ssh-dss 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
------------------------------------------------------------
Can change permissions = Yes
Can change owner/group = Yes
Can execute arbitrary command = No
Can create symlink/hardlink = Yes/No
Can lookup user groups = No
Can duplicate remote files = No
Can check available space = No
Can calculate file checksum = No
Native text (ASCII) mode transfers = Yes
------------------------------------------------------------
Additional information
The server supports these SFTP extensions:
newline="\r\n"

**************************************************************
This method returns Exit Code 1, says 0 bytes transferred
The file actually transfers fine
*************************************************************



###########################################################################
##
## UPLOAD Text Files to Test Directory on the Server.
##
## Version: 3.3
## Date: June 9, 2011
###########################################################################



########################################################################################

$VersionLine = "Script Version: 3.3 Date: June 9, 2011"



$uploadServer = "xx.com"
$uploadPort = "xx"

$Processor = $Env:Processor_Architecture
$UserName = "xx"
$PWDFile = "C:\xx\xxs\" + $Env:Username + "_" + $UserName + "@" + $uploadServer + ".pwd"

$connector = '@' + $uploadServer + ':' + $uploadPort

########################################################################################


$SaveCulture = [System.Threading.Thread]::CurrentThread.CurrentCulture
[System.Globalization.CultureInfo] $NewCulture = "en-US"
[System.Threading.Thread]::CurrentThread.CurrentCulture = $NewCulture



if(Test-Path $PWDFile)

## If the Password file exits for the UserName,
## then read the password and create the Credentials.

{
$Password = Get-Content $PWDFile | ConvertTo-SecureString
$Credential = New-Object System.Management.Automation.PsCredential $UserName,$Password
}

else

## If the Password file does not exist for UserName,
## then query the user for the password and create the password file.

{
$Credential = Get-Credential $UserName
$Credential.Password | ConvertFrom-SecureString | Set-Content $PWDFile
}



$ProgramFiles = [Environment]::GetFolderPath("ProgramFiles")

if ( $Processor -ne "x86" )
{
$ProgramFiles += " (x86)"
}

$ProgramFiles += "\WinSCP\WinSCP.com"

## Winscp session Information

$startInfo = New-Object Diagnostics.ProcessStartInfo
$startInfo.Filename = $ProgramFiles
$startInfo.UseShellExecute = $false
$startInfo.RedirectStandardInput = $true
$startInfo.CreateNoWindow = $true
$startInfo.RedirectStandardOutput = $true



## Create arrays to hold Winscp Sessions and Logs

$winscp = @(1..10)
[String[]]$logfiles = (1..10)

$counter = 1




$winscp[$counter] = [System.Diagnostics.Process]::Start($startInfo)
$winscp[$counter].StandardInput.WriteLine("option echo off")
$winscp[$counter].StandardInput.WriteLine("option batch abort")
$winscp[$counter].StandardInput.WriteLine("option confirm off")
$winscp[$counter].StandardInput.WriteLine("option transfer binary")
$winscp[$counter].StandardInput.WriteLine("option reconnecttime 20")
$winscp[$counter].StandardInput.WriteLine("open " + $Credential.GetNetworkCredential().UserName +":" + $Credential.GetNetworkCredential().Password + $connector)
$winscp[$counter].StandardInput.WriteLine("cd TestDirectory")
$winscp[$counter].StandardInput.WriteLine("lcd C:\TestExitCode")
$winscp[$counter].StandardInput.WriteLine("put -preservetime -nopermissions C:\TestExitCode\Sample.txt")

Write-Host "Opened Winscp Session $counter `n"

$winscp[$counter].StandardInput.Close()
$logfiles[$counter] = $winscp[$counter].StandardOutput.ReadToEnd()
$winscp[$counter].WaitForExit()
$ExitCode = $winscp[$counter].ExitCode

Write-Host "Closed Winscp Session $counter`n"
Write-Host "Session $counter finished with exit code $ExitCode`n"
Write-Host $logfiles[$counter]

************************************************************************************
Here is the log
************************************************************************************

PS C:\JAPAN\Scripts> C:\JAPAN\Scripts\TestExitCode.ps1
Opened Winscp Session 1

Closed Winscp Session 1

Session 1 finished with exit code 1

winscp> option echo off
echo off
winscp> option batch abort
batch abort
winscp> option confirm off
confirm off
winscp> option transfer binary
transfer binary
winscp> option reconnecttime 20
reconnecttime 20
winscp> open xx:xx@xx.com:xx
Searching for host...
Connecting to host...
Authenticating...
Using username "xx".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] xx@xx.com
winscp> cd TestDirectory
/TestDirectory
winscp> lcd C:\TestExitCode
C:\TestExitCode
winscp> put -preservetime -nopermissions C:\TestExitCode\Sample.txt
C:\TestExitCode\Sample.txt | 0 KiB | 0.0 KiB/s | binary | 100%
winscp>


*************************************************************************************

## Another method that returns exit code 0 but still lists 0 bytes transferred

*************************************************************************************

$Command_String = '"option echo off" '
$Command_String += '"option batch abort" '
$Command_String += '"option confirm off" '
$Command_String += '"option transfer binary" '
$Command_String += '"open '
$Command_String += $Credential.GetNetworkCredential().UserName
$Command_String += ':'
$Command_String += $Credential.GetNetworkCredential().Password
$Command_String += '@' + $uploadServer + ':' + $uploadPort + '" '
$Command_String += '"cd TestDirectory" '
$Command_String += '"lcd C:\TestExitCode " '
$Command_String += '"put -preservetime -nopermissions C:\TestExitCode\Sample2.txt" '
$Command_String += '"exit "'

$LogFile = [System.IO.Path]::GetTempFileName()

Write-Host "Connecting to WinSCP `n `n"

& $ProgramFiles /Command $Command_String >>$Logfile 2>&1
$TestExitCode = $lastExitCode

Write-Host "Exited with exit code $TestExitCode `n" -foregroundcolor "green"

$message = [System.IO.File]::ReadAllText($Logfile)

Write-Host $message

Remove-Item -Force $Logfile


Write-Host "Press ENTER to QUIT the application." -foregroundcolor "green"
[Console]::ReadKey($true) | Out-Null



*************************************************************
Here is the Log
*************************************************************


Connecting to WinSCP


Exited with exit code 0

echo off
batch abort
confirm off
transfer binary
Searching for host...
Connecting to host...
Authenticating...
Using username "xx".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] xx@xx.com
/TestDirectory
C:\TestExitCode
C:\TestExitCode\Sample2.txt | 0 KiB | 0.0 KiB/s | binary | 100%

Press ENTER to QUIT the application.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Please post a log file.
_________________
Martin Prikryl
Craig Brennan
[View user's profile]

Joined: 2012-01-23
Posts: 2
Here are the logs you were asking for:

. 2012-01-24 11:21:23.478 --------------------------------------------------------------------------
. 2012-01-24 11:21:23.479 WinSCP Version 4.3.6 (Build 1655) (OS 6.1.7601 Service Pack 1)
. 2012-01-24 11:21:23.479 Configuration: HKEY_CURRENT_USER\Software\Martin Prikryl\WinSCP 2\
. 2012-01-24 11:21:23.479 Local account: XXXXXX\craig_brennan
. 2012-01-24 11:21:23.479 Login time: 2012年1月24日 11:21:23
. 2012-01-24 11:21:23.479 --------------------------------------------------------------------------
. 2012-01-24 11:21:23.479 Session name: xxxxxx@xxxxx.com (Modified stored session)
. 2012-01-24 11:21:23.479 Host name: xxxxxxx.com (Port: xxx)
. 2012-01-24 11:21:23.479 User name: xxxxxx (Password: Yes, Key file: No)
. 2012-01-24 11:21:23.479 Tunnel: No
. 2012-01-24 11:21:23.479 Transfer Protocol: SFTP (SCP)
. 2012-01-24 11:21:23.480 Ping type: -, Ping interval: 30 sec; Timeout: 15 sec
. 2012-01-24 11:21:23.480 Proxy: none
. 2012-01-24 11:21:23.480 SSH protocol version: 2; Compression: No
. 2012-01-24 11:21:23.480 Bypass authentication: No
. 2012-01-24 11:21:23.480 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No
. 2012-01-24 11:21:23.480 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2012-01-24 11:21:23.480 SSH Bugs: -,-,-,-,-,-,-,-,-
. 2012-01-24 11:21:23.480 SFTP Bugs: -,-
. 2012-01-24 11:21:23.480 Return code variable: Autodetect; Lookup user groups: Yes
. 2012-01-24 11:21:23.480 Shell: default
. 2012-01-24 11:21:23.480 EOL: 0, UTF: 2
. 2012-01-24 11:21:23.480 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
. 2012-01-24 11:21:23.480 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
. 2012-01-24 11:21:23.480 Local directory: default, Remote directory: home, Update: No, Cache: Yes
. 2012-01-24 11:21:23.480 Cache directory changes: Yes, Permanent: Yes
. 2012-01-24 11:21:23.480 DST mode: 1
. 2012-01-24 11:21:23.480 --------------------------------------------------------------------------
. 2012-01-24 11:21:23.480 Looking up host "xxxxx.com"
. 2012-01-24 11:21:23.484 Connecting to xxx.xxx.xxx.94 port xxx
. 2012-01-24 11:21:23.676 Server version: SSH-2.0-1.00 FlowSsh: WinSSHD 5.05
. 2012-01-24 11:21:23.676 Using SSH protocol version 2
. 2012-01-24 11:21:23.676 We claim version: SSH-2.0-WinSCP_release_4.3.6
. 2012-01-24 11:21:23.768 Doing Diffie-Hellman group exchange
. 2012-01-24 11:21:24.162 Doing Diffie-Hellman key exchange with hash SHA-1
. 2012-01-24 11:21:24.449 Host key fingerprint is:
. 2012-01-24 11:21:24.449 ssh-dss 1024 xx:xx:xx:xx:xx:xx:xx:xx:0d:18:3f:b9:d1:8d:05:f1
. 2012-01-24 11:21:24.450 Initialised AES-256 SDCTR client->server encryption
. 2012-01-24 11:21:24.450 Initialised HMAC-SHA1 client->server MAC algorithm
. 2012-01-24 11:21:24.450 Initialised AES-256 SDCTR server->client encryption
. 2012-01-24 11:21:24.450 Initialised HMAC-SHA1 server->client MAC algorithm
! 2012-01-24 11:21:24.843 Using username "xxxxxx".
. 2012-01-24 11:21:24.935 Prompt (7, SSH password, , &Password: )
. 2012-01-24 11:21:24.935 Using stored password.
. 2012-01-24 11:21:24.936 Sent password
. 2012-01-24 11:21:25.079 Access granted
. 2012-01-24 11:21:25.172 Opened channel for session
. 2012-01-24 11:21:25.553 Started a shell/command
. 2012-01-24 11:21:25.553 --------------------------------------------------------------------------
. 2012-01-24 11:21:25.554 Using SFTP protocol.
. 2012-01-24 11:21:25.554 Doing startup conversation with host.
> 2012-01-24 11:21:25.554 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2012-01-24 11:21:25.647 Type: SSH_FXP_VERSION, Size: 22, Number: -1
. 2012-01-24 11:21:25.647 SFTP version 4 negotiated.
. 2012-01-24 11:21:25.647 Server requests EOL sequence "\r\n".
. 2012-01-24 11:21:25.647 We will use UTF-8 strings when appropriate
. 2012-01-24 11:21:25.647 Getting current directory name.
. 2012-01-24 11:21:25.647 Getting real path for '.'
> 2012-01-24 11:21:25.647 Type: SSH_FXP_REALPATH, Size: 10, Number: 16
< 2012-01-24 11:21:25.743 Type: SSH_FXP_NAME, Size: 19, Number: 16
. 2012-01-24 11:21:25.743 Real path is '/'
. 2012-01-24 11:21:25.743 Startup conversation with host finished.
< 2012-01-24 11:21:25.743 Script: Active session: [1] xxxxxx@xxxxxx.com
> 2012-01-24 11:21:25.743 Script: cd TestDirectory
. 2012-01-24 11:21:25.743 Cached directory change via "TestDirectory" to "/TestDirectory".
. 2012-01-24 11:21:25.744 Getting current directory name.
< 2012-01-24 11:21:25.744 Script: /TestDirectory
> 2012-01-24 11:21:25.744 Script: lcd C:\TestExitCode
< 2012-01-24 11:21:25.744 Script: C:\TestExitCode
> 2012-01-24 11:21:25.744 Script: put -preservetime -nopermissions C:\TestExitCode\Sample2.txt
. 2012-01-24 11:21:25.745 Copying 1 files/directories to remote directory "/TestDirectory"
. 2012-01-24 11:21:25.745 PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 01; Resume: S (102400); CalcS: No; Mask:
. 2012-01-24 11:21:25.745 TM: B; ClAr: No; CPS: 0; ExclM(No):
. 2012-01-24 11:21:25.745 AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2012-01-24 11:21:25.745 File: "C:\TestExitCode\Sample2.txt"
. 2012-01-24 11:21:25.745 Copying "C:\TestExitCode\Sample2.txt" to remote directory started.
. 2012-01-24 11:21:25.745 Binary transfer mode selected.
. 2012-01-24 11:21:25.745 Opening remote file.
> 2012-01-24 11:21:25.745 Type: SSH_FXP_OPEN, Size: 52, Number: 259
< 2012-01-24 11:21:25.839 Type: SSH_FXP_HANDLE, Size: 11, Number: 259
> 2012-01-24 11:21:25.839 Type: SSH_FXP_WRITE, Size: 844, Number: 774
> 2012-01-24 11:21:25.840 Type: SSH_FXP_CLOSE, Size: 11, Number: 1028
> 2012-01-24 11:21:25.840 Type: SSH_FXP_SETSTAT, Size: 56, Number: 521
< 2012-01-24 11:21:26.223 Type: SSH_FXP_STATUS, Size: 35, Number: 774
< 2012-01-24 11:21:26.223 Type: SSH_FXP_STATUS, Size: 35, Number: 1028
< 2012-01-24 11:21:26.223 Status code: 0
< 2012-01-24 11:21:26.223 Type: SSH_FXP_STATUS, Size: 35, Number: 521
< 2012-01-24 11:21:26.223 Status code: 0
> 2012-01-24 11:21:26.224 Script: exit
. 2012-01-24 11:21:26.224 Closing connection.
. 2012-01-24 11:21:26.224 Sending special code: 12
. 2012-01-24 11:21:26.224 Sent EOF message





Craig Brennan wrote:
I just updated to 4.3.6 from 4.3.5
I use scripting and have had no problems going back 4 or 5 versions.
Using Windows 7 Ultimate, SFTP-4 and scripting to MS Server 2008 Std.
I use 2 methods, command line script and sessions.
Sessions returns error code 1, 0 bytes transferred.
Command line returns error code 0, 0 bytes transferred.
Both acutally transfer fine.
This only applies to uploads.
Downloads work fine.

Here arethe code and logs for both methods:

Session protocol = SSH-2
SSH implementation = 1.00 FlowSsh: WinSSHD 5.05
Encryption algorithm = aes
Compression = No
File transfer protocol = SFTP-4
------------------------------------------------------------
Server host key fingerprint
ssh-dss 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
------------------------------------------------------------
Can change permissions = Yes
Can change owner/group = Yes
Can execute arbitrary command = No
Can create symlink/hardlink = Yes/No
Can lookup user groups = No
Can duplicate remote files = No
Can check available space = No
Can calculate file checksum = No
Native text (ASCII) mode transfers = Yes
------------------------------------------------------------
Additional information
The server supports these SFTP extensions:
newline="\r\n"

**************************************************************
This method returns Exit Code 1, says 0 bytes transferred
The file actually transfers fine
*************************************************************



###########################################################################
##
## UPLOAD Text Files to Test Directory on the Server.
##
## Version: 3.3
## Date: June 9, 2011
###########################################################################



########################################################################################

$VersionLine = "Script Version: 3.3 Date: June 9, 2011"



$uploadServer = "xx.com"
$uploadPort = "xx"

$Processor = $Env:Processor_Architecture
$UserName = "xx"
$PWDFile = "C:\xx\xxs\" + $Env:Username + "_" + $UserName + "@" + $uploadServer + ".pwd"

$connector = '@' + $uploadServer + ':' + $uploadPort

########################################################################################


$SaveCulture = [System.Threading.Thread]::CurrentThread.CurrentCulture
[System.Globalization.CultureInfo] $NewCulture = "en-US"
[System.Threading.Thread]::CurrentThread.CurrentCulture = $NewCulture



if(Test-Path $PWDFile)

## If the Password file exits for the UserName,
## then read the password and create the Credentials.

{
$Password = Get-Content $PWDFile | ConvertTo-SecureString
$Credential = New-Object System.Management.Automation.PsCredential $UserName,$Password
}

else

## If the Password file does not exist for UserName,
## then query the user for the password and create the password file.

{
$Credential = Get-Credential $UserName
$Credential.Password | ConvertFrom-SecureString | Set-Content $PWDFile
}



$ProgramFiles = [Environment]::GetFolderPath("ProgramFiles")

if ( $Processor -ne "x86" )
{
$ProgramFiles += " (x86)"
}

$ProgramFiles += "\WinSCP\WinSCP.com"

## Winscp session Information

$startInfo = New-Object Diagnostics.ProcessStartInfo
$startInfo.Filename = $ProgramFiles
$startInfo.UseShellExecute = $false
$startInfo.RedirectStandardInput = $true
$startInfo.CreateNoWindow = $true
$startInfo.RedirectStandardOutput = $true



## Create arrays to hold Winscp Sessions and Logs

$winscp = @(1..10)
[String[]]$logfiles = (1..10)

$counter = 1




$winscp[$counter] = [System.Diagnostics.Process]::Start($startInfo)
$winscp[$counter].StandardInput.WriteLine("option echo off")
$winscp[$counter].StandardInput.WriteLine("option batch abort")
$winscp[$counter].StandardInput.WriteLine("option confirm off")
$winscp[$counter].StandardInput.WriteLine("option transfer binary")
$winscp[$counter].StandardInput.WriteLine("option reconnecttime 20")
$winscp[$counter].StandardInput.WriteLine("open " + $Credential.GetNetworkCredential().UserName +":" + $Credential.GetNetworkCredential().Password + $connector)
$winscp[$counter].StandardInput.WriteLine("cd TestDirectory")
$winscp[$counter].StandardInput.WriteLine("lcd C:\TestExitCode")
$winscp[$counter].StandardInput.WriteLine("put -preservetime -nopermissions C:\TestExitCode\Sample.txt")

Write-Host "Opened Winscp Session $counter `n"

$winscp[$counter].StandardInput.Close()
$logfiles[$counter] = $winscp[$counter].StandardOutput.ReadToEnd()
$winscp[$counter].WaitForExit()
$ExitCode = $winscp[$counter].ExitCode

Write-Host "Closed Winscp Session $counter`n"
Write-Host "Session $counter finished with exit code $ExitCode`n"
Write-Host $logfiles[$counter]

************************************************************************************
Here is the log
************************************************************************************

PS C:\JAPAN\Scripts> C:\JAPAN\Scripts\TestExitCode.ps1
Opened Winscp Session 1

Closed Winscp Session 1

Session 1 finished with exit code 1

winscp> option echo off
echo off
winscp> option batch abort
batch abort
winscp> option confirm off
confirm off
winscp> option transfer binary
transfer binary
winscp> option reconnecttime 20
reconnecttime 20
winscp> open xx:xx@xx.com:xx
Searching for host...
Connecting to host...
Authenticating...
Using username "xx".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] xx@xx.com
winscp> cd TestDirectory
/TestDirectory
winscp> lcd C:\TestExitCode
C:\TestExitCode
winscp> put -preservetime -nopermissions C:\TestExitCode\Sample.txt
C:\TestExitCode\Sample.txt | 0 KiB | 0.0 KiB/s | binary | 100%
winscp>


*************************************************************************************

## Another method that returns exit code 0 but still lists 0 bytes transferred

*************************************************************************************

$Command_String = '"option echo off" '
$Command_String += '"option batch abort" '
$Command_String += '"option confirm off" '
$Command_String += '"option transfer binary" '
$Command_String += '"open '
$Command_String += $Credential.GetNetworkCredential().UserName
$Command_String += ':'
$Command_String += $Credential.GetNetworkCredential().Password
$Command_String += '@' + $uploadServer + ':' + $uploadPort + '" '
$Command_String += '"cd TestDirectory" '
$Command_String += '"lcd C:\TestExitCode " '
$Command_String += '"put -preservetime -nopermissions C:\TestExitCode\Sample2.txt" '
$Command_String += '"exit "'

$LogFile = [System.IO.Path]::GetTempFileName()

Write-Host "Connecting to WinSCP `n `n"

& $ProgramFiles /Command $Command_String >>$Logfile 2>&1
$TestExitCode = $lastExitCode

Write-Host "Exited with exit code $TestExitCode `n" -foregroundcolor "green"

$message = [System.IO.File]::ReadAllText($Logfile)

Write-Host $message

Remove-Item -Force $Logfile


Write-Host "Press ENTER to QUIT the application." -foregroundcolor "green"
[Console]::ReadKey($true) | Out-Null



*************************************************************
Here is the Log
*************************************************************


Connecting to WinSCP


Exited with exit code 0

echo off
batch abort
confirm off
transfer binary
Searching for host...
Connecting to host...
Authenticating...
Using username "xx".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] xx@xx.com
/TestDirectory
C:\TestExitCode
C:\TestExitCode\Sample2.txt | 0 KiB | 0.0 KiB/s | binary | 100%

Press ENTER to QUIT the application.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Thanks for your report.
I have sent you an email with a development version of WinSCP to address you have used to register on this forum.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
This bug has been added to the tracker:
http://winscp.net/tracker/show_bug.cgi?id=794
_________________
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