Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

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

olegur

timeout

tried timeout now and it seems to have fixed it, was also getting 0x1 error in task scheduler. Thanks :D #lifesaver
olegur

winscp .net waiting for log update and dispatching events

I have issues with my script where it says "timeout waiting for winscp to respond" and i am clueless as to what it could be
using .net for powershell btw

# Load WinSCP .NET assembly

Add-Type -Path "WinSCPnet.dll"

# Session.FileTransferred event handler
 
function FileTransferred
{
    param($e)
 
    if ($e.Error -eq $Null)
    {
        Write-Host ("Upload of {0} succeeded" -f $e.FileName)
    }
    else
    {
        Write-Host ("Upload of {0} failed: {1}" -f $e.FileName, $e.Error)
    }
 
    if ($e.Chmod -ne $Null)
    {
        if ($e.Chmod.Error -eq $Null)
        {
            Write-Host ("Permisions of {0} set to {1}" -f $e.Chmod.FileName, $e.Chmod.FilePermissions)
        }
        else
        {
            Write-Host ("Setting permissions of {0} failed: {1}" -f $e.Chmod.FileName, $e.Chmod.Error)
        }
 
    }
    else
    {
        Write-Host ("Permissions of {0} kept with their defaults" -f $e.Destination)
    }
 
    if ($e.Touch -ne $Null)
    {
        if ($e.Touch.Error -eq $Null)
        {
            Write-Host ("Timestamp of {0} set to {1}" -f $e.Touch.FileName, $e.Touch.LastWriteTime)
        }
        else
        {
            Write-Host ("Setting timestamp of {0} failed: {1}" -f $e.Touch.FileName, $e.Touch.Error)
        }
 
    }
    else
    {
        # This should never happen during "local to remote" synchronization
        Write-Host ("Timestamp of {0} kept with its default (current time)" -f $e.Destination)
    }
}

# Set up session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::Ftp
    HostName = "FTPHOST"
    PortNumber = 21
    UserName = "FTPUSERNAME"
    Password = "FTPPASSWORD"
}

$session = New-Object WinSCP.Session

try
{
        # Will continuously report progress of synchronization
        $session.add_FileTransferred( { FileTransferred($_) } )
       
        #Logging
        $session.DebugLogPath ="C:\WinSCP\Log\winscp-debug.log"
        #$DateTime = Get-Date -format yyyy/MM/dd-HH.mm.ss
        #$session.SessionLogPath ="C:\WinSCP\log\$DateTime-WinSCP.log"

        # Connect
        $session.Open($sessionOptions)
 
        # Synchronize files
        $synchronizationResult = $session.SynchronizeDirectories(
            [WinSCP.SynchronizationMode]::Local, "\\LOCAL\felles\Timelapse", "/lerftp/", $False)
 
        # Throw on any error
        $synchronizationResult.Check()
}
finally
{
        # Disconnect, clean up
        $session.Dispose()
    }
 
    exit 0
catch [Exception]
{
    Write-Host ("Error: {0}" -f $_.Exception.Message)
    exit 1
}



and i attached my debug log