473,386 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Capturing output from external process

Hi,

I used the following code Jochen Kalmbach suggested to run an external
program:

System::Diagnostics::ProcessStartInfo *si = new
System::Diagnostics::ProcessStartInfo();
si->UseShellExecute = false;
si->WorkingDirectory = S"D:\\Promela\\";
si->FileName = "D:\\Promela\\PAN.exe";
si->Arguments = "-a -v";
si->CreateNoWindow = true;
si->RedirectStandardOutput = true;
System::Diagnostics::Process *p =
System::Diagnostics::Process::Start(si);
System::String *output = p->StandardOutput->ReadToEnd();
p->WaitForExit();
System::Windows::Forms::MessageBox::Show(output);

The problem is that the string output is empty, while I know there is
output produced. I think the problem may be that the StandardOutput is
read before the output is produced, though I'm not sure. I tried
switching the oreder of the ReadToEnd() and the WaitForExit line, but
this doesn't help.

Does anyone know how to capture the output correctly?

Thanks in advance,

Marcel

Jan 30 '06 #1
1 1221
> Does anyone know how to capture the output correctly?

Yes.

http://msdn.microsoft.com/library/de...and_output.asp

Brian
Jan 30 '06 #2

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

Similar topics

4
by: Avi Kak | last post by:
Is there a Python function in any of the standard-distribution modules that does what the backticks do in Perl? I want to run an external command and I'd like its output to be captured directly...
3
by: Yuan HOng | last post by:
In my program I have to call an external program and parse its output. For that I use the os.popen2 function, and then read the output stream. But the complexity is that the external program...
2
by: Hoegje | last post by:
I am writing a C++ program, which should create a sub- process to start a telnet session to another server. Then it should login to that server (on the telnet login) and execute one or more...
1
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my...
2
by: Harikumar G | last post by:
Friends, I have a C# console application for verifying a signature of an encrypted, this is done thru the Process.Startinfo method, My dos application for the decryption is gpg.exe (gnupgi) ...
3
by: iforsyth | last post by:
Hi. Running an app with System.Diagnostics.Process process with: Sample code: myproc = New System.Diagnostics.Process() strPgm = "myapp.exe" strArgs = "" myproc.StartInfo = New
5
by: Luigi | last post by:
Hi to all! I'd like to execute an external program capturing the stdout/stderr messages at "real-time". I mean that I don't want to wait for the end of the process. If I write a code like this:...
6
by: Ed Leafe | last post by:
I've been approached by a local business that has been advised that they need to start capturing and archiving their instant messaging in order to comply with Sarbanes-Oxley. The company is largely...
1
by: Elpoca | last post by:
Hi: I am trying to capture std output from a console application and redirect it to a textbox. The code below works the first time the process is started, but on subsequent starts it fails to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...

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.