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

filipd

thanks, my mistake.
I'll adjust this timeout parameter and try the job again
martin

The SessionOptions.Timeout is of type TimeSpan.

The 300 gets converted by PowerShell to TimeSpan 00:00:00.0000300 what rounds to zero later.
filipd

Timeout set to 0 ?
I've lost you there : the code looks as follows :

try
{
# Load WinSCP .NET assembly
Add-Type -Path "C:\Program Files (x86)\WINSCP\WinSCPnet.dll"

# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$sessionOptions.HostName = "XXXXXXX"
$sessionOptions.UserName = "XXXXXXX"
$sessionOptions.Password = "XXXXXXX"
$sessionOptions.Timeout = 300
$sessionOptions.SshHostKeyFingerprint = "ssh-rsa XXXXXX"


$session = New-Object WinSCP.Session

try
{
# Connect
$session.ExecutablePath = "C:\Program Files (x86)\WINSCP\winscp.exe"
$Session.SessionLogPath = "C:\Scripts\copy.log"
# $Session.DebugLogPath = "C:\Scripts\copydebug.log"
$session.Open($sessionOptions)

# Synchronize files
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
$transferOptions.SpeedLimit = 6000

$transferResult_Data = $session.SynchronizeDirectories([WinSCP.SynchronizationMode]::Local, "E:\PRD_BACKUPS\DATA\", "/hana/hana-backup/PRD/data/",$true,$false,[WinSCP.SynchronizationCriteria]::Time,$transferOptions)
$transferResult_Data.Check()
$transferResult_Logs = $session.SynchronizeDirectories([WinSCP.SynchronizationMode]::Local, "E:\PRD_BACKUPS\LOGS\", "/hana/hana-backup/PRD/log/",$true,$false,[WinSCP.SynchronizationCriteria]::Time,$transferOptions)
$transferResult_Logs.Check()


}
finally
{
# Disconnect, clean up
$session.Dispose()
}
Send-MailMessage -From "hostname" -To "XXXXXXXXX" -Subject "synchronization of backupfiles (DATA & LOGS) from <hostname> to <hostname> finished OK" -SmtpServer "yyy"
exit 0
}
catch [Exception]
{
$ErrorMessage = $_.Exception.Message
Send-MailMessage -From "hostname" -To "XXXXXXXXX" -Subject "synchronization of backupfiles (DATA or LOGS) from <hostname> to <hostname> FAILED !" -SmtpServer "yyy" -Body "Error message is $ErrorMessage"
exit 1
}
martin

Why do you have the timeout set to 0? That does not make any sense.
filipd

Hello

Job failed again last night.
New log to be found in attachment.

Br

Filip
filipd

ok, we'll do.
I'll keep you informed (job only runs during the night)
martin

Re: Timeout waiting for external console to complete the command

Can you please try the latest version first?
filipd

Timeout waiting for external console to complete the command

Hello

I have a PS script (using WinSCP .NET assembly) to synchronize a directory between Windows (target) and Linux (source).
Most of the time, the script fails with the following error message :

2016-01-17 23:27:08.238 Type: SSH_FXP_CLOSE, Size: 13, Number: 236635908
* 2016-01-17 23:27:08.613 (ECommand) **Copying files from remote side failed.**
* 2016-01-17 23:27:08.613 Timeout waiting for external console to complete the command.
< 2016-01-17 23:27:08.613 Script: Copying files from remote side failed.
< 2016-01-17 23:27:08.676 Script: Timeout waiting for external console to complete the command.
. 2016-01-17 23:27:08.769 Script: Failed
> 2016-01-17 23:27:19.551 Script: exit
. 2016-01-17 23:27:19.566 Script: Exit code: 1
. 2016-01-17 23:27:19.566 Closing connection.
. 2016-01-17 23:27:19.629 Sending special code: 12
. 2016-01-17 23:27:19.629 Sent EOF message


The logfile can be found in attachment.
Thanks for helping me out

Filip