Hi,
Just wondering if anyone knows how to process a command response, such as a "ping", in C#? For example, I know if you make the call, using the System.Diagnostics namespace, "Process process = Process.Start("cmd", "/C ping localhost > ping.txt");" starts the command prompt and runs the ping command and then stores the output into the ping.txt file. I'm just wondering if there's a way to avoid the copying of the output to a text file, and routing it to a local string variable in my code, so that I can process it directly? Or is processing the output via the text file the only way?
Thanks in advanced!
-Weeg
1 3612
Hi,
Just wondering if anyone knows how to process a command response, such as a "ping", in C#? For example, I know if you make the call, using the System.Diagnostics namespace, "Process process = Process.Start("cmd", "/C ping localhost > ping.txt");" starts the command prompt and runs the ping command and then stores the output into the ping.txt file. I'm just wondering if there's a way to avoid the copying of the output to a text file, and routing it to a local string variable in my code, so that I can process it directly? Or is processing the output via the text file the only way?
Thanks in advanced!
-Weeg
- Process p = new Process();
-
p.StartInfo.FileName = "COMMAND";
-
p.StartInfo.Arguments = file;
-
p.StartInfo.UseShellExecute = false;
-
p.StartInfo.RedirectStandardOutput = true;
-
p.Start();
-
String output = p.StandardOutput.ReadToEnd();
Sign in to post your reply or Sign up for a free account.
Similar topics
by: RL |
last post by:
Hello Perl gurus,
1. I have a web page where I can push a button (dospawn.html).
2. This button calls a CGI script (spawnboss.cgi)
3. spawnboss.cgi calls a forking perl script (forkme.pl)
4....
|
by: Bob Murdoch |
last post by:
I'm developing an intranet application using W2k server and IE5.5 - 6.x
clients. I've got one particular function that calls a stored procedure to
update a number of records, depending on user...
|
by: Div / |
last post by:
I have a very strange problem here. I have a wrapper class for a
command line MyProgram.exe. When i run it from the command prompt
(MyProgram.exe), it runs perfectly. So there is not problem with...
|
by: jcrouse |
last post by:
This is kind of a continuation of another thread that was somewhat resolved:
Well, the dilemma seems to be this. I want to be able to hide the DOS box
AND pause the code until execution is...
|
by: RSH |
last post by:
Hi,
I have an ASP .Net web page that creates a temp directory on the server then
it is using the File.Copy command to move a file to a temp download
directory, Then I am doing a...
|
by: Benzi Eilon |
last post by:
I have written a C# application which should run as a Windows
Service. I must avoid having multiple instances of the application
on one machine so I inserted the following code at the beginning
of...
|
by: =?Utf-8?B?Z215ZXJz?= |
last post by:
Hello,
I am attempting to start a cmd.exe process and pass several .vbs scripts
(with additional parameters) and then read the output from the scripts and
make "notes" in a DataTable (the...
|
by: =?Utf-8?B?VkIgSm9ubmll?= |
last post by:
I am at my witless end here, please help!
I have an ASP.Net aspx web page, hosted on Windows Server 2003, that
receives a query string with the path to an autocad drawing file selected
from a...
|
by: Samuel A. Falvo II |
last post by:
I have a shell script script.sh that launches a Java process in the
background using the &-operator, like so:
#!/bin/bash
java ... arguments here ... &
In my Python code, I want to invoke...
|
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...
|
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...
|
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...
|
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...
|
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)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
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
|
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...
| |