jlwilson
Member
Ok, here is another doozy for me. I am trying to figure out how to retreive the output of a process in string format. Here is why...
First off, I'm trying to get away from ugly black MS-DOS Windows! Ewww! Secondly, there are times when I'd like to actually parse the output of a command, line for line. For instance, I may want to have a window that allows a user to type in or select a servername to ping. Once they click the ping button, I'd like to be able to parse the data from the ping output so that I can translate strings containing the phrase "Reply from" to "Online" or "Request Timed Out" to "Offline".
I come from a background in Perl as far as my programming capabilities and one thing I like about VB.NET that I didn't like in perl was the ability to create easy to use graphic user interfaces quickly.
If I could figure out how to read in process output as a string, I'm sure it would open up new horizons for me.
Anyone got an idea. The below code is what I tried and many of you may laugh at it, but it shows you how I was thinking.
This fails miserably. Basically, I want the ping output to show up in my textbox.
First off, I'm trying to get away from ugly black MS-DOS Windows! Ewww! Secondly, there are times when I'd like to actually parse the output of a command, line for line. For instance, I may want to have a window that allows a user to type in or select a servername to ping. Once they click the ping button, I'd like to be able to parse the data from the ping output so that I can translate strings containing the phrase "Reply from" to "Online" or "Request Timed Out" to "Offline".
I come from a background in Perl as far as my programming capabilities and one thing I like about VB.NET that I didn't like in perl was the ability to create easy to use graphic user interfaces quickly.
If I could figure out how to read in process output as a string, I'm sure it would open up new horizons for me.
Anyone got an idea. The below code is what I tried and many of you may laugh at it, but it shows you how I was thinking.
VB.NET:
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] strOutput [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String
[/COLOR][/SIZE][SIZE=2]Process.Start([/SIZE][SIZE=2][COLOR=#800000]"cmd"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"/c title Pinging "[/COLOR][/SIZE][SIZE=2] & strRouter & [/SIZE][SIZE=2][COLOR=#800000]" &&ping "[/COLOR][/SIZE][SIZE=2] & strRouter & [/SIZE][SIZE=2][COLOR=#800000]" -t"[/COLOR][/SIZE][SIZE=2])
strOutput = Process.Start([/SIZE][SIZE=2][COLOR=#800000]"cmd"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"/c title Pinging "[/COLOR][/SIZE][SIZE=2] & strDigi & [/SIZE][SIZE=2][COLOR=#800000]" &&ping "[/COLOR][/SIZE][SIZE=2] & strDigi & [/SIZE][SIZE=2][COLOR=#800000]" -t"[/COLOR][/SIZE][SIZE=2]).StandardOutput.ReadLine.ToString
[/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].TextBox1.Text = strOutput
[/SIZE]
This fails miserably. Basically, I want the ping output to show up in my textbox.