- martin
Post a reply
Topic review
- martin
Re: timeout waiting for external console to complete the command
- conrad
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:
Thanks for the speedy response.
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
Re: timeout waiting for external console to complete the command
A have added some observations to the tracker. Does it look familiar to your case?
- conrad
Apparently this has been around for some time
Further looking around on this site shows that this is bug #24.
- conrad
timeout waiting for external console to complete the command
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:
The script file works fine from a command prompt window.
My program code:
The process continues to run: my log object (above) reports "FTP running..." indefinitely.
thanks
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:
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:
...
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