473,549 Members | 2,715 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2920

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.Diagnost ics;

class Class1
{
static void Main(string[] args)
{
ProcessStartInf o procInfo = new ProcessStartInf o("ping", "127.0.0.1" );
procInfo.Create NoWindow= false;
procInfo.UseShe llExecute = false;
procInfo.Window Style = ProcessWindowSt yle.Hidden;
procInfo.Redire ctStandardOutpu t = true;
Process pro = new Process();
pro.StartInfo = procInfo;
pro.Start();
Console.WriteLi ne(pro.Standard Output.ReadToEn d());
Console.ReadLin e(); // just to wait...
}
}
"me" <me@discussions .microsoft.com> wrote in message
news:8A******** *************** ***********@mic rosoft.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.StandardOut put.ReadToEnd() into a string so that i
can find a text in it?

Thanks

"Someone" wrote:
using System;
using System.Diagnost ics;

class Class1
{
static void Main(string[] args)
{
ProcessStartInf o procInfo = new ProcessStartInf o("ping", "127.0.0.1" );
procInfo.Create NoWindow= false;
procInfo.UseShe llExecute = false;
procInfo.Window Style = ProcessWindowSt yle.Hidden;
procInfo.Redire ctStandardOutpu t = true;
Process pro = new Process();
pro.StartInfo = procInfo;
pro.Start();
Console.WriteLi ne(pro.Standard Output.ReadToEn d());
Console.ReadLin e(); // just to wait...
}
}
"me" <me@discussions .microsoft.com> wrote in message
news:8A******** *************** ***********@mic rosoft.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
105770
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: System.out.print((char)27 + "[2J");
1
5363
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 application (VB.NET) will start a process, redirect its stdout and capture that process' output, displaying it in a window. I've written a component...
7
6343
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 problem double percent_00_01 = 1D / 10000D double percent_00_10 = 1D / 1000D double percent_01_00 = 1D / 100D double percent_10_00 = ...
5
11201
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 to avoid the overhead of writing to the console if it is not visible, eg I am running inside a WinForm application. thanks
5
6326
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 complete project to show what happens. If anybody has an idea of how to fix this, please let me know. Yes I am aware that this is all in .Net 2....
17
4201
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 console using System.Console.WriteLine if thge project has its "Output Type" to "Windows Application". However I can write to stdio if i set output...
5
11493
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 I may be doing wrong, thanks
3
11355
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 it myself. Here's the URL: http://www.codeproject.com/dotnet/ConsolePasswordInput.asp
6
5704
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 possible to use Console.Writeln when you have a Webservice. I don't think it's possible but just to be sure I ask you?
1
2031
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 error: The CLR has been unable to transition from COM context 0x1a2008 to COM context 0x1a2178 for 60 seconds. The thread that owns the destination...
0
7518
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7444
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7954
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7467
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7805
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6039
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5367
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1932
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1054
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.