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.diagnos tics.process class and its ability to redirect stdoutput/stdinput and thought it would be perfect -- apparently not.
Here is the relevant code:
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.
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.diagnos tics.process class and its ability to redirect stdoutput/stdinput and thought it would be perfect -- apparently not.
Here is the relevant code:
Code:
Diagnostics.Process curl = new Diagnostics.Process();
String response = null;
curl.StartInfo.FileName = curlPath;
curl.StartInfo.UseShellExecute = false;
curl.StartInfo.RedirectStandardOutput = true;
curl.StartInfo.Arguments = "www.msn.com";
curl.start();
curl.WaitForExit(40000);
if (curl.HasExited) {
response = curl.StandardOutput.ReadToEnd;
} else {
curl.Kill();
}
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.
Comment