473,800 Members | 2,613 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

redirecting stdout

Im trying to capture the stdout from running a process from within my app.
I've been dinking around using the code straight off the MS site. i can get
"ipconfig / all" (for example) to send back its output, but not (in this
case) "nasm -v" , which displays version information.
whats happening?

slightly modified MS code:
Dim myProcessStartI nfo As New ProcessStartInf o("c:\nasm\nasm ", "-v")

myProcessStartI nfo.UseShellExe cute = False

myProcessStartI nfo.RedirectSta ndardOutput = True

myProcess.Start Info = myProcessStartI nfo

myProcessStartI nfo.CreateNoWin dow = True

myProcess.Start ()

Dim myStreamReader As StreamReader = myProcess.Stand ardOutput

' Read the standard output of the spawned process.

Dim myString As String = myStreamReader. ReadToEnd

txtOutput.Text = myString

thanks,

patrick
Nov 21 '05 #1
3 2960
Hallo Patrick!

"Patrick Porter" <pa*****@ironkn ee.net> schrieb:
Im trying to capture the stdout from running a process from within my app.
I've been dinking around using the code straight off the MS site. i can
get "ipconfig / all" (for example) to send back its output, but not (in
this case) "nasm -v" , which displays version information.
whats happening?


<URL:http://dotnet.mvps.org/dotnet/samples/misc/RedirectConsole .zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
i adapted your stuff into mine, and i have the same problem....i can run
ipconfig /all and get the output fine, but i cant get the output from
requesting the version info from nasm (c:\nasm\nasm.e xe -v). why is it that
i can get some stuff but not all?

also, thanks alot for the code sample. great stuff

patrick
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:eR******** ******@TK2MSFTN GP15.phx.gbl...
Hallo Patrick!

"Patrick Porter" <pa*****@ironkn ee.net> schrieb:
Im trying to capture the stdout from running a process from within my
app. I've been dinking around using the code straight off the MS site. i
can get "ipconfig / all" (for example) to send back its output, but not
(in this case) "nasm -v" , which displays version information.
whats happening?


<URL:http://dotnet.mvps.org/dotnet/samples/misc/RedirectConsole .zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
"Patrick Porter" <pa*****@ironkn ee.net> wrote in message
news:tC******** ******@twister. rdc-kc.rr.com...
Im trying to capture the stdout from running a process from within my app.
I've been dinking around using the code straight off the MS site. i can get "ipconfig / all" (for example) to send back its output, but not (in this
case) "nasm -v" , which displays version information.
Since one works and the other doesn't -

Could "nasm" be writing this to stderr, instead of stdout?

HTH,

First guess
whats happening?

slightly modified MS code:
Dim myProcessStartI nfo As New ProcessStartInf o("c:\nasm\nasm ", "-v")

myProcessStartI nfo.UseShellExe cute = False

myProcessStartI nfo.RedirectSta ndardOutput = True

myProcess.Start Info = myProcessStartI nfo

myProcessStartI nfo.CreateNoWin dow = True

myProcess.Start ()

Dim myStreamReader As StreamReader = myProcess.Stand ardOutput

' Read the standard output of the spawned process.

Dim myString As String = myStreamReader. ReadToEnd

txtOutput.Text = myString

thanks,

patrick

Nov 21 '05 #4

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

Similar topics

2
12717
by: Birch | last post by:
I have a python script that uses the print function throughout, and as well uses calls to os.system() to spawn DOS commandline executables. My issue is that I redirect all of the output from this script to a file (including that which is printed by the spawned programs) via the redirect (">") function on a Win2K Command Prompt. In the captured output however, the output from the os.system() calls ALWAYS comes before the output from the...
3
3762
by: David Douard | last post by:
Hi everybody, let me explain by problem: I am working on an application which consists in a C++ dll (numeric computations) and a Python IHM (Python/Tk), which must run under Linux and win32. My problem is the C++ lib does write stuffs on its stdout, and I would like to print those messages in a Tk frame. When I run the computation, it has it's own thread. So my question is : how van I redirect the dll's stdout to something I can
3
3435
by: Laszlo Zsolt Nagy | last post by:
Hello, I have this code: s = smtplib.SMTP() s.set_debuglevel(1) s.connect(host=smtp_host) s.set_debuglevel(0) log("Connected, sending e-mail") sys.stdout.flush()
15
3116
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 Process(myStartInfo) // this gets shown straight away MessageBox.Show("Process Started"); string s =...
9
1770
by: Fuzzyman | last post by:
Hello, I'm trying to redirect standard out in a single namespace. I can replace sys.stdout with a custom object - but that affects all namespaces. There will be code running simultaneously that could import sys afterwards - so I don't want to make the change in the sys module.
8
5790
by: Morpheus | last post by:
I am trying to test a function that outputs text to the standard output, presumably using a cout call. I do not have access to the source, but need to test the output. Is this possible? I can technically create an executable that calls the function and then using a command prompt call the exexutable using the > output.txt redirector but I would prefer to do everything within the application itself. Is there a way for force an output...
1
2597
by: pp4175 | last post by:
Hello Everyone, I am currently working on writing a GUI wrapper for a Menu driven DOS Program. What I was looking on doing is redirecting stdout/stdin to a stream and read/write similar to a file. My issue is that I try to read from the stdout stream and never get anything only if the program has exited. Is there a way of reading the redirected stdout from a DOS program in say real time? I have tried the async (BeginOutputReadLine) and...
10
7639
by: SamG | last post by:
How could i make, from inside the program, to have the stdout and stderr to be printed both to a file as well the terminal(as usual).
5
2615
by: =?gb2312?B?yMvR1MLkyNXKx8zs0cSjrM37vKvM7NHEsru8+7z | last post by:
I wanna print the log to both the screen and file, so I simulatered a 'tee' class Tee(file): def __init__(self, name, mode): file.__init__(self, name, mode) self.stdout = sys.stdout sys.stdout = self
4
9736
by: ElderGeek | last post by:
Hi, all. I am coding in C on Linux, and using an external library provided by others. This library generates a batch of error/warning messages to stdout, which I do not want to see. Before each function call to the external library, I can insert the following: freopen("/dev/null", "w", stdout); However, after the function call I cannot figure out how to reroute stdout to the console. I tried early in the program defining: FILE...
0
10507
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10279
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9092
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7582
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6815
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5473
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4150
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2948
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.