jholzer
February 17th, 2006, 03:09 AM
Hi!
I´m currently programming a GUI for a Command-Line-Based System. The administration is done with a command-line-Admin-Tool similar to Windows´ CMD-Dos-Box.
Unfortunately i cannot run the admin-commands on their own, because the only run in this cmd-line-based gui, which seems to be an stand-alone interpreter, not a dos-box running seperate programs...
Also there is no API available i could use.
What i´d like to do is to call a DOS-Box/Admin-Tool via the Process-Object and send my commands to it via the StandardInput-Object.
Sending works fine, but when I do the reading from StandardOutput-Stream, i cannot find an end-mark for my while-Statement.
(For testing-purposes i send everything to the system-console in order to see, what comes back from my process)
string sto = null;
string ste = null;
while ( ((sto = process.StandardOutput.ReadLine()) != null) || ((ste = process.StandardError.ReadLine()) != null) )
{
if (sto != null)
System.Console.WriteLine(sto);
if (ste != null)
System.Console.WriteLine(ste);
sto = null;
ste = null;
}
When the command has finished, the loop hangs in the ReadLine-Statements.
Peeking into the stream doesn´t work and hangs also...
How could i do this?
Thanks a lot!
J.
I´m currently programming a GUI for a Command-Line-Based System. The administration is done with a command-line-Admin-Tool similar to Windows´ CMD-Dos-Box.
Unfortunately i cannot run the admin-commands on their own, because the only run in this cmd-line-based gui, which seems to be an stand-alone interpreter, not a dos-box running seperate programs...
Also there is no API available i could use.
What i´d like to do is to call a DOS-Box/Admin-Tool via the Process-Object and send my commands to it via the StandardInput-Object.
Sending works fine, but when I do the reading from StandardOutput-Stream, i cannot find an end-mark for my while-Statement.
(For testing-purposes i send everything to the system-console in order to see, what comes back from my process)
string sto = null;
string ste = null;
while ( ((sto = process.StandardOutput.ReadLine()) != null) || ((ste = process.StandardError.ReadLine()) != null) )
{
if (sto != null)
System.Console.WriteLine(sto);
if (ste != null)
System.Console.WriteLine(ste);
sto = null;
ste = null;
}
When the command has finished, the loop hangs in the ReadLine-Statements.
Peeking into the stream doesn´t work and hangs also...
How could i do this?
Thanks a lot!
J.