PC Review


Reply
Thread Tools Rate Thread

c# console app

 
 
=?Utf-8?B?bWU=?=
Guest
Posts: n/a
 
      22nd Jun 2005
How do i trap the incomming data to the console?
lets say I wrote a console app that pings another computer in the network.
I see the following in the console:

Reply from 180.100.24.5: bytes=32 time<10ms TTL=127
Reply from 180.100.24.5: bytes=32 time<10ms TTL=127
Reply from 180.100.24.5: bytes=32 time<10ms TTL=127

I want to trap all this into a string. How can I do this?

Thanks in advance
 
Reply With Quote
 
 
 
 
jabailo@texeme.com
Guest
Posts: n/a
 
      23rd Jun 2005

You can use the ProcessInfo class and trap standard output from any DOS
command.

me wrote:
> How do i trap the incomming data to the console?
> lets say I wrote a console app that pings another computer in the network.
> I see the following in the console:
>
> Reply from 180.100.24.5: bytes=32 time<10ms TTL=127
> Reply from 180.100.24.5: bytes=32 time<10ms TTL=127
> Reply from 180.100.24.5: bytes=32 time<10ms TTL=127
>
> I want to trap all this into a string. How can I do this?
>
> Thanks in advance

 
Reply With Quote
 
=?Utf-8?B?bWU=?=
Guest
Posts: n/a
 
      23rd Jun 2005
I already use processInfo but how do i trap the text that is written on the
console?

Thanks

"(E-Mail Removed)" wrote:

>
> You can use the ProcessInfo class and trap standard output from any DOS
> command.
>
> me wrote:
> > How do i trap the incomming data to the console?
> > lets say I wrote a console app that pings another computer in the network.
> > I see the following in the console:
> >
> > Reply from 180.100.24.5: bytes=32 time<10ms TTL=127
> > Reply from 180.100.24.5: bytes=32 time<10ms TTL=127
> > Reply from 180.100.24.5: bytes=32 time<10ms TTL=127
> >
> > I want to trap all this into a string. How can I do this?
> >
> > Thanks in advance

>

 
Reply With Quote
 
Someone
Guest
Posts: n/a
 
      23rd Jun 2005
using System;
using System.Diagnostics;

class Class1
{
static void Main(string[] args)
{
ProcessStartInfo procInfo = new ProcessStartInfo("ping", "127.0.0.1");
procInfo.CreateNoWindow= false;
procInfo.UseShellExecute = false;
procInfo.WindowStyle = ProcessWindowStyle.Hidden;
procInfo.RedirectStandardOutput = true;
Process pro = new Process();
pro.StartInfo = procInfo;
pro.Start();
Console.WriteLine(pro.StandardOutput.ReadToEnd());
Console.ReadLine(); // just to wait...
}
}


"me" <(E-Mail Removed)> wrote in message
news:8A640634-3BD2-4EA1-A60D-(E-Mail Removed)...
>I already use processInfo but how do i trap the text that is written on the
> console?
>
> Thanks
>
> "(E-Mail Removed)" wrote:
>
>>
>> You can use the ProcessInfo class and trap standard output from any DOS
>> command.
>>
>> me wrote:
>> > How do i trap the incomming data to the console?
>> > lets say I wrote a console app that pings another computer in the
>> > network.
>> > I see the following in the console:
>> >
>> > Reply from 180.100.24.5: bytes=32 time<10ms TTL=127
>> > Reply from 180.100.24.5: bytes=32 time<10ms TTL=127
>> > Reply from 180.100.24.5: bytes=32 time<10ms TTL=127
>> >
>> > I want to trap all this into a string. How can I do this?
>> >
>> > Thanks in advance

>>




 
Reply With Quote
 
=?Utf-8?B?bWU=?=
Guest
Posts: n/a
 
      24th Jun 2005
Thanks Someone,
But how can I trap pro.StandardOutput.ReadToEnd() into a string so that i
can find a text in it?

Thanks

"Someone" wrote:

> using System;
> using System.Diagnostics;
>
> class Class1
> {
> static void Main(string[] args)
> {
> ProcessStartInfo procInfo = new ProcessStartInfo("ping", "127.0.0.1");
> procInfo.CreateNoWindow= false;
> procInfo.UseShellExecute = false;
> procInfo.WindowStyle = ProcessWindowStyle.Hidden;
> procInfo.RedirectStandardOutput = true;
> Process pro = new Process();
> pro.StartInfo = procInfo;
> pro.Start();
> Console.WriteLine(pro.StandardOutput.ReadToEnd());
> Console.ReadLine(); // just to wait...
> }
> }
>
>
> "me" <(E-Mail Removed)> wrote in message
> news:8A640634-3BD2-4EA1-A60D-(E-Mail Removed)...
> >I already use processInfo but how do i trap the text that is written on the
> > console?
> >
> > Thanks
> >
> > "(E-Mail Removed)" wrote:
> >
> >>
> >> You can use the ProcessInfo class and trap standard output from any DOS
> >> command.
> >>
> >> me wrote:
> >> > How do i trap the incomming data to the console?
> >> > lets say I wrote a console app that pings another computer in the
> >> > network.
> >> > I see the following in the console:
> >> >
> >> > Reply from 180.100.24.5: bytes=32 time<10ms TTL=127
> >> > Reply from 180.100.24.5: bytes=32 time<10ms TTL=127
> >> > Reply from 180.100.24.5: bytes=32 time<10ms TTL=127
> >> >
> >> > I want to trap all this into a string. How can I do this?
> >> >
> >> > Thanks in advance
> >>

>
>
>
>

 
Reply With Quote
 
=?Utf-8?B?bWU=?=
Guest
Posts: n/a
 
      24th Jun 2005
I see how you did it Thanks alottttttttttt

"me" wrote:

> How do i trap the incomming data to the console?
> lets say I wrote a console app that pings another computer in the network.
> I see the following in the console:
>
> Reply from 180.100.24.5: bytes=32 time<10ms TTL=127
> Reply from 180.100.24.5: bytes=32 time<10ms TTL=127
> Reply from 180.100.24.5: bytes=32 time<10ms TTL=127
>
> I want to trap all this into a string. How can I do this?
>
> Thanks in advance

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I want to read a character from console, while writing somethingto the console. Jade Lee Microsoft C# .NET 2 9th Jul 2007 09:31 PM
How to change _buffer_ size of console window (or can runas inherit console props)? Alex Blekhman Microsoft Windows 2000 CMD Promt 4 18th Mar 2005 10:07 AM
Console.Writeline hangs if user click into the console window Urs Eichmann Microsoft VB .NET 3 20th Jul 2004 07:48 AM
Press View->Java Console and no console appears Grant Watson Windows XP Internet Explorer 0 26th Mar 2004 04:25 PM
How to set a fixed line in a console application liek UNIX console AA Microsoft C# .NET 1 6th Dec 2003 03:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:24 AM.