Redirect StandardOutput problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a perl script that I am calling from vb.net as a process. I need to get the standard
output and display it in a text box. The problem I am having is that extra blank lines are
being added to the standard output, 2 of them per line. I have no idea why - and if I
run the same script in the command line the output is normal (no extra 2 lines per line).
Can someone point me in the right direction? Thanks.

Dim MyProcess As New Process
MyProcess.StartInfo.UseShellExecute = False
'redirect the standard output
MyProcess.StartInfo.RedirectStandardOutput = True
'do not create a command window
MyProcess.StartInfo.CreateNoWindow = True
'set the file name
MyProcess.StartInfo.FileName = "c:\perl\bin\perl.exe"
MyProcess.StartInfo.Arguments = "e:\test_template.pl"

'start the process
MyProcess.Start()

'grab the contents of the standard output
Dim srOut As StreamReader = MyProcess.StandardOutput

Dim sOut As String = srOut.ReadToEnd

txtText = sOut

'wait until the program exits
MyProcess.WaitForExit()
 
Hi Darren,

I use this (it is not really optimized)

Dim sr As IO.StreamReader = p.StandardOutput
Dim sb As New System.Text.StringBuilder("")
Dim input As Integer = sr.Read
Do Until input = -1
sb.Append(ChrW(input))
input = sr.Read
Loop

I hope this helps?

Cor
 
Thanks for the suggestion, but it gave me the same undesired result. Is it possible that I need to change the encoding or something like that, and if so how can that be done on standard output?
 
Hi Darren,

Would be strange to me, normally it can only send 8 byte extended ascii to
the standard output device in my opinion. (Not that I am sure of this,
however this are mostly classic DOS commands which are used).

Do you see strange characters when you start it by hand? Or empty rows?

Cor
 
The output when directed to the screen is perfect, no extra line breaks. Only when I redirect the standardoutput to a string or to a textbox do the extra line breaks appear.
 
Hi Darren,

Are you really intrested what it is or can you do it with this
redirectstring = redirectstring.replace(chr(10),"")
redirectstring = redirectstring.replace(chr(13),"")

Cor
 
Back
Top