B
Benjamin Hall
I want to launch a process ftp.exe and monitor it in realtime so I can read
and write to the console window based on the returned text. How do I do
this?
ie launch ftp.exe then process.standardinput.writeline("open ftp.domain.com
port") then read, then write, then read etc etc
The examples I found only allow you to read from the console after the
application has exited.
This example does everything automatically in the output window, the results
is what I want to capture realtime as its output to the console window.
Dim myProcess As Process = New Process
myProcess.StartInfo.FileName = "ftp.exe"
myProcess.StartInfo.Arguments = "-s:C:\ftp.txt"
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal
myProcess.StartInfo.UseShellExecute = True
myProcess.Start()
myProcess.WaitForExit()
However if I change the code to redirect the ouput as so, I can only get a
result from the output once the process exits.
myProcess.StartInfo.UseShellExecute = False
myProcess.StartInfo.RedirectStandardInput = True
myProcess.StartInfo.RedirectStandardOutput = True
myProcess.StartInfo.RedirectStandardError = True
myProcess.Start()
Console.WriteLine(myProcess.StandardOutput.ReadToEnd())
myProcess.WaitForExit()
and write to the console window based on the returned text. How do I do
this?
ie launch ftp.exe then process.standardinput.writeline("open ftp.domain.com
port") then read, then write, then read etc etc
The examples I found only allow you to read from the console after the
application has exited.
This example does everything automatically in the output window, the results
is what I want to capture realtime as its output to the console window.
Dim myProcess As Process = New Process
myProcess.StartInfo.FileName = "ftp.exe"
myProcess.StartInfo.Arguments = "-s:C:\ftp.txt"
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal
myProcess.StartInfo.UseShellExecute = True
myProcess.Start()
myProcess.WaitForExit()
However if I change the code to redirect the ouput as so, I can only get a
result from the output once the process exits.
myProcess.StartInfo.UseShellExecute = False
myProcess.StartInfo.RedirectStandardInput = True
myProcess.StartInfo.RedirectStandardOutput = True
myProcess.StartInfo.RedirectStandardError = True
myProcess.Start()
Console.WriteLine(myProcess.StandardOutput.ReadToEnd())
myProcess.WaitForExit()