Output problem executing curl command with ssh

0 votes
asked Mar 20, 2011 by Zeokat (240 points)
edited Mar 21, 2011

I testing the example included WinFormRExec, i´m trying to use curl but seems impossible receive output correctly.

I´m using a simple command with curl:

curl -o filesumi.bin http://web.com/file100mb.bin

If i use:

string line = shell.ReadLine();

It reads first two lines of curl output but the progress (next lines) aren´t show showed in real time, they are showed at once at the end when curl finish.

I know that curl writes output using StandardError and not StandardOutput, perhaps it´s the problem.

Anyways if you know how to capture in real time curl output will be very usefull for my project.

Thanks in advance for your help.

2 Answers

+1 vote
answered Mar 20, 2011 by Zeokat (240 points)
edited Mar 20, 2011

Well... after research a few, seems that exists shell.ReadChar() , and this captures correctly the curl ouput, don´t know exactly why shell.ReadLine() fails.

Anyways i think that can solve situation with ReadChar().

Again answering myself :P , perhpaps it can be usefull for other users.

Thanks anyways.

+1 vote
answered Mar 21, 2011 by Lukas Matyska (55,430 points)
edited Mar 21, 2011

The curl command displays the current state of the transfer on a line without sending the Line Feed character (LF - 0x0A) until the process is finshed.

The Shell.ReadLine() method reads the output up to the first occurance of the LF character. If the process takes long time the ReadLine method times out (no LF is received during the transfer).

On the other hand, the Shell.ReadChar() method reads from output immediately if any character is available. So if the characters are received continuously during a transfer the Timeout exception doesn't appear.

commented Mar 22, 2011 by Zeokat (240 points)
Thanks for the reply, now all is clear. Thanks.
...