473,321 Members | 1,748 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,321 software developers and data experts.

c# console app

me
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
Jul 21 '05 #1
5 2912

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

Jul 21 '05 #2
me
I already use processInfo but how do i trap the text that is written on the
console?

Thanks

"ja*****@texeme.com" 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

Jul 21 '05 #3
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" <me@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com...
I already use processInfo but how do i trap the text that is written on the
console?

Thanks

"ja*****@texeme.com" 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


Jul 21 '05 #4
me
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" <me@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com...
I already use processInfo but how do i trap the text that is written on the
console?

Thanks

"ja*****@texeme.com" 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


Jul 21 '05 #5
me
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

Jul 21 '05 #6

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

Similar topics

19
by: Dave | last post by:
Hi, I have done some research, trying to Clear The Screen in java code. The first option was the obv: system.out.print("\n\n\n\n\n\n\n\n\n\n\n\n"); then i heard about this method:...
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...
7
by: shawnk | last post by:
Hello Everyone How do you format format numbers right-justified using Console.WriteLine(), i.e I need to line up numbers in vertical columns and the MSDN documentation is pretty poor Here is the...
5
by: Barry Mossman | last post by:
Hi, can I detect whether my class is running within the context of a Console application, vs say a WinForm's application ? also does anyone know whether the compiler or runtime is smart enough...
5
by: Publicjoe | last post by:
I am working on a little app which uses colour in the console window. I have created a class to extend the console functionality but the ClearScreen method does not work correctly. I am enclosing a...
17
by: MumboJumbo | last post by:
Hi I have a really basic question hopefully some can help me with: Can you write a (i.e. one) C# project that works from the cmd line and gui? I seems if i write a GUI app it can't write to...
5
by: portroe | last post by:
Hi I am using console.Writeline in my simple program. I do not however see anything happening in the output window when I debug, there are also no error messages, Has anybody a tip on what...
3
by: julianmoors | last post by:
Hey, Currently I'm writing a VB.NET/1.1 app and I need to mask the input for the password field. Does anyone know how to do this in VB? I've seen a C# example, but wouldn't know how to convert...
6
by: tony | last post by:
Hello! When you have windows forms you have the same possibility as when you have a Console application to use Console.Writeln to write whatever on the screen. Now to my question: Is it...
1
by: John Wright | last post by:
I am running a console application that connects to an Access database (8 million rows) and converts it to a text file and then cleans and compacts the database. When it runs I get the following...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.