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
- 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.