Problem with reading from StandardOutput

Y

Yash

Hi,
Through my VB .NET code , I am trying to invoke a perl script. My aim
is to write lines to the script and read from it.
With ProcInfo
.Arguments = Enricher.EnrichScript + " " + enArgs
.RedirectStandardInput = True
.RedirectStandardOutput = True
.RedirectStandardError = True
.UseShellExecute = False
.CreateNoWindow = True
End With

Me.EnrichProcess.StartInfo = ProcInfo
Me.EnrichProcess.Start()

The effective invocation is C:\perl\bin\perl a.pl 1 2 3.

I am able to write one line to the script, which reaches the script
properly:
Me.EnrichProcess.StandardInput.WriteLine("ABC")
After this the VB .NET program tries to read a line
stat = Me.EnrichProcess.StandardOutput.ReadLine()
This statment hangs.

The script when run manually at command prompt, immediately outputs a
string and a newline character after reading a line. But when invoked
programmatically , the ReadLine hangs( blocks).

Can somebody point out the problem?

Thanks
Yash
 
H

Herfried K. Wagner [MVP]

* (e-mail address removed) (Yash) scripsit:
Through my VB .NET code , I am trying to invoke a perl script. My aim
is to write lines to the script and read from it.
With ProcInfo
.Arguments = Enricher.EnrichScript + " " + enArgs
.RedirectStandardInput = True
.RedirectStandardOutput = True
.RedirectStandardError = True
.UseShellExecute = False
.CreateNoWindow = True
End With

Me.EnrichProcess.StartInfo = ProcInfo
Me.EnrichProcess.Start()

The effective invocation is C:\perl\bin\perl a.pl 1 2 3.

I am able to write one line to the script, which reaches the script
properly:
Me.EnrichProcess.StandardInput.WriteLine("ABC")
After this the VB .NET program tries to read a line
stat = Me.EnrichProcess.StandardOutput.ReadLine()
This statment hangs.

The script when run manually at command prompt, immediately outputs a
string and a newline character after reading a line. But when invoked
programmatically , the ReadLine hangs( blocks).

Does this sample work?

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

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