473,513 Members | 3,895 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Redirect StandardOutput problem

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()
Nov 20 '05 #1
6 2192
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
Nov 20 '05 #2
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?

"Cor Ligthert" wrote:
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

Nov 20 '05 #3
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
Nov 20 '05 #4
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.

"Cor Ligthert" wrote:
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

Nov 20 '05 #5
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
Nov 20 '05 #6
No, I need to keep the valid line feeds in the file. Thanks.

"Cor Ligthert" wrote:
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

Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
412
by: John Lewin | last post by:
I've recently discovered the value of using existing console applications in managed .net apps. Unfortunately, I've stumbled into a problem with a particular console application that check's crc info on CDs. Using either the StandardError or StandardOutput streams read, readline or peek methods causes an immediate block that doesn't release...
0
1518
by: darren | last post by:
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...
3
10373
by: Al Cohen | last post by:
I'll start by warning that I'm a newbie to C# (but I've been programming for 25 years), so I may just be doing something reallyreally dumb. I'm writing a C# wrapper for a command-line application (pscp.exe, a secure file-copy app that's part of the excellent PuTTY SSH package). Getting pscp.exe to run properly was a piece of cake using...
15
3070
by: Matt Burland | last post by:
I'm having a problem with redirecting the StandardOutput of a process that I use to run a DOS program in my application. The problem is that I when I start my process (which I do in a separate thread) I can't read anything from the stdout before the process actually finishes. If I do something like this: Process myProcess = new...
1
1790
by: Franco Gustavo | last post by:
How can redirect the standard output to a file from inside the same process. It can be easily done if one process launches another process with startinfo.RedirectStandardOutput to true. Process p = new Process();
2
3172
by: Ivan Lam | last post by:
Hi all, Thanks for reading my post!!! I am facing a problem that I cannot redirect StandartOutput and StandardInput at the same time without closing the executive. Actually, I have a console application named "etm.exe", I would like to call it in my .net (VC) application. What I want to do is when the user type some command in my .net...
0
1225
by: Alison | last post by:
Hi, all, I started an application by using process and wanted to redirect the output to a textbox in VB .Net. I used newprocess.standoutput.readline since I wanted the display to be timely . The problem I am experiencing with readline is I cannot redirect the entire output. What actually happends is if there is an empty line between the output,...
0
1481
by: BasicQ | last post by:
I am running an executable from my aspx page with the click of a button. A date is passed as an argument. I am able to get the standardoutput from the Process(Exe) into the label of my page after the process has completed executing. My problem is I need to get the output in the label simultaneously when the EXE is running, not after it has...
4
11922
by: Zenon | last post by:
I have a C# application which interacts with an HP UNIX box via PSFTP. I have run in to a problem where the maximum amount of characters I can redirect is 1024. This number leads me to believe that it is not random and perhaps there is some flushing that needs to occur before I can read more. I couldn't find anything about the 1024 char...
0
7270
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7178
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7397
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7563
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5703
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5102
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4757
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3252
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.