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

Trying to capture stdoutput, but Diagnostics.Process object causes process to hang

Hi, I'm trying to capture the standard output from a program called cURL.

Running the program from the command line as such:

>curl www.youtube.com

will write out the HTML page returned by YouTube.

My objective is to "capture" and manipulate this data. I read about the systems.diagnostics.process class and its ability to redirect stdoutput/stdinput and thought it would be perfect -- apparently not.

Here is the relevant code:

Expand|Select|Wrap|Line Numbers
  1. Diagnostics.Process curl = new Diagnostics.Process();
  2. String response = null;
  3. curl.StartInfo.FileName = curlPath;
  4. curl.StartInfo.UseShellExecute = false;
  5. curl.StartInfo.RedirectStandardOutput = true;
  6. curl.StartInfo.Arguments = "www.msn.com";
  7. curl.start();
  8. curl.WaitForExit(40000);
  9. if (curl.HasExited) {
  10.     response = curl.StandardOutput.ReadToEnd;
  11. } else {
  12.     curl.Kill();
  13. }
  14.  
When the process is started, rather than spitting out the HTML of YouTube.com, I get a meter displaying download progress. Obviously this is something built into cURL, but why is it doing it? I want the process to be ran just as it is from the command line. The major issue, though, is that cURL will just hang after downloading a few bytes.

What's going on here? Why is it behaving differently than when it's called from the command line? And how can I "simulate" the command line? I tried executing cmd.exe instead, and then writing the command "curl www.youtube.com" to stdin, but that caused even more problems...

Any help/explanation is appreciated.
Jul 30 '10 #1
2 1402
Alex Papadimoulis
26 Expert
While I'm not very familiar with how cURL works, I'm curious as to why you are trying to download a page using a command line?

The WebClient class provides methods to retreive web pages from a URL in the same manner that it looks like you're using.
Aug 3 '10 #2
Frinavale
9,735 Expert Mod 8TB
You can use the HttpWebRequest class to make a request to a website and retrieve the HTML for the page.

-Frinny
Aug 3 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Marcel Hug | last post by:
Hello NG ! How can i get all file handles which a process object (get from Process.GetProcesses();) is using or has open? Thanks and regards Marcel Hug
6
by: gizmo | last post by:
I have a requirement to initiate more than one instance of an application using the filenames. (the example below will start two instances of MS Word). My problem is that I need to kill each...
1
by: Bucky Pollard | last post by:
I have a web service that needs to create a batch file and call it (since there are no APIs for the functionality I am looking for). I am using the Process and ProcessStartInfo objects. When I try...
0
by: Phillip Galey | last post by:
I'm trying to use the Process object to have RUNAS run DOS commands. I have no problem getting the Process object to run DOS commands and return the resulting text back to the program. However,...
1
by: Ram | last post by:
Hey, I'm trying to use the "gacutil" exec to register an assembly form an aspx file using the Process Object. Here's the code: Dim objProc As Process objProc = new Process()
2
by: james | last post by:
Hello, I would like to instance a new System.Diagnostics.Process object that is the current application, but I can't see a quick way of doing this. I know how to "start" a process, but it's...
5
by: Jon Davis | last post by:
I'm hosting a .NET console application in a .NET Windows Service using System.Diagnostics.Process. How do I block the debugger dialogue from appearing? Thanks, Jon
2
by: Mario Beutler | last post by:
How can I check if a process a .net process or a "normal" win32 process? Mario
0
by: eashokan | last post by:
Hi.. I am able to get the process (as object) running in the sysetm through process id. I need to trigger the event that corresponds to the process (object) i got. Note that the Process object i...
3
by: Maura Jenkins | last post by:
Hi Everyone ... I have a bunch of BLOB data (MS Word and PDF docs mainly) stored in SQL 2005; no problems with ordinary CRUD operations but I'd like to read my data and "feed it" to a Process()...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.