Topic "timeout waiting for external console to complete the command"

Author Message
conrad
[View user's profile]

Joined: 2008-12-03
Posts: 3
Location: Louisville
Running winscp.com with a script file that FTP puts a few hundred files works fine when I type it in a cmd.exe window, but when I try to use it as a process object in my .Net 3.5 program, I get a pop-up dialog with the above message after about thirty seconds. The process continues to run, but no more files get transferred.

Is there a way to get around this timeout?

I'm running WinSCP version 4.1.7 on windows XP, visual studio 2008.

Here's my script file:
Code:
open creynolds@winsrvops
option confirm off
option batch on
cd attachment
lcd W:\ibm\WebSphere\AppServer\profiles\ecstg\installedApps\WC_ecstg_cell\WC_ecstg.ear\Stores.war\APHConsumerDirect
lcd attachment
put *.*
lcd ..
lcd upload
cd ..
cd upload
put *.*
lcd ..
lcd images\catalog
cd ..
cd images\catalog
put *.*
bye


The script file works fine from a command prompt window.

My program code:

Code:
...
    Sub FTPfiles(ByVal localdir As String)
        ' Purpose:  FTP the image files, etc from ecstage to web server
        ' Created:  conrad dec 2008
        ' Modified:
        Const THISSUB As String = "FTPfiles"
        Dim proc As Process
        Try
            BuildScriptFile()
            StartProc(proc, My.Settings.FTPFilePath & "\winscp.com", _
                "/script=""" & My.Settings.FTPFilePath & "\WSCPromotionBatch.txt""", 10)
            Do
                If Not proc.HasExited Then
                    proc.Refresh()
                    If proc.Responding Then
                        log.Comment("FTP running...", THISSUB)
                    Else
                        log.Comment("FTP not responding.", THISSUB)
                    End If
                End If
            Loop While Not proc.WaitForExit(10 * 1000)
            log.Comment("FTP process exit code:" & proc.ExitCode, THISSUB)
            proc.Close()
        Catch ex As Exception
            Throw New Exception("Error in " & THISSUB, ex)
        Finally
            proc = Nothing
        End Try
    End Sub

    Sub StartProc(ByRef proc As Process, ByVal cmd As String, ByVal parms As String, ByVal waitseconds As Integer)
        ' Purpose:  Start up the specified command as a process
        ' Returns:  A Process variable for your process.
        ' Created:  conrad dec 2008
        ' Modified:
        Const THISSUB As String = "StartProc"
        Dim procStartInfo As ProcessStartInfo
        Try
            proc = New Process()
            procStartInfo = New ProcessStartInfo(cmd, parms)
            procStartInfo.UseShellExecute = False
            procStartInfo.RedirectStandardError = True
            procStartInfo.RedirectStandardOutput = True
            proc.StartInfo = procStartInfo
            proc.Start()
            proc.WaitForExit(waitseconds * 1000)
        Catch ex As Exception
            Throw New Exception("Error in " & THISSUB, ex)
        Finally
            procStartInfo = Nothing
        End Try
    End Sub

The process continues to run: my log object (above) reports "FTP running..." indefinitely.

thanks
Advertisements
conrad
[View user's profile]

Joined: 2008-12-03
Posts: 3
Location: Louisville
Further looking around on this site shows that this is bug #24.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
A have added some observations to the tracker. Does it look familiar to your case?
_________________
Martin Prikryl
conrad
[View user's profile]

Joined: 2008-12-03
Posts: 3
Location: Louisville
Yes, that did the trick! I had to drain the output stream, just as you suggested. The section of code (for the use of future generations) looks like this now:
Code:

        Dim proc As Process
        Dim sr As StreamReader
        Dim outputSink As String
        Try
            BuildScriptFile()
            procOutput = New StringBuilder
            proc = New Process
            StartProc(proc, My.Settings.FTPFilePath & "\winscp.com", _
                "/script=""" & My.Settings.FTPFilePath & "\WSCPromotionBatch.txt""", 0)
            ' We have to drain the output stream, else it will fill up the
            ' buffer, and winscp will come to a halt.
            sr = proc.StandardOutput
            outputSink = sr.ReadToEnd
            log.Comment("FTP process exit code:" & proc.ExitCode, THISSUB)
            proc.Close()

Thanks for the speedy response.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
See guide to using WinSCP from .NET.
_________________
Martin Prikryl
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Or see article dealing with the error in general.
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