Reading realtime from ftp.exe process window

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()
 
H

Herfried K. Wagner [MVP]

* "Benjamin Hall said:
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.

<http://dotnet.mvps.org/dotnet/samples/miscsamples/downloads/RedirectConsole.zip>
 
C

Chad Z. Hower aka Kudzu

Benjamin Hall said:
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?

Is there a reason you are tyring to control the command line FTP instead of
just using the FTP protocol directly?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top