Subject: Re: [libssh2] code snippet [was: libssh2_channel_read_stderr always in blocking mode ?]

Re: [libssh2] code snippet [was: libssh2_channel_read_stderr always in blocking mode ?]

From: Thomas Harding <thomas.harding_at_laposte.net>
Date: Sun, 5 Aug 2007 16:06:55 +0200

On Wed, Aug 01, 2007 at 05:56:53PM +0200, Thomas Harding wrote:
>
> >>On Tue, 31 Jul 2007, Thomas Harding wrote:
> >Daniel Stenberg <daniel_at_haxx.se>
> >
> >>My problem is that while using libssh2_channel_read_stderr, it seems to
> >>wait infinitely for data when no data is available, whatever channel is or
> >>is not in blocking mode.
> >
> >Can you please provide a complete small source snippet that reproduces the
> >problem?
>
> Well, maybe the better will be to me to write such this, but it is not
> done... hope following code will be enough explicit.

Here is the code snippet in attachment.

This can be compiled in lieue of example/simple/ssh2.c

Note I'm a "C" newbie, and have not network programming experience.

So, then running this example:
        ./ssh2 127.0.0.1 tom '*****' 'cat xulu' 1 100 >foo
               ^IP ^user ^pass ^command ^display errors if 1 ^if given, poll timeout in ms. If not, running in blocking mode

        * ./ssh2 127.0.0.1 tom '*****' 'cat xulu' 1 100 >foo
> display error message. OK
        * ./ssh2 127.0.0.1 tom '*****' 'cat mbox' 1 100 >foo
> records mbox in foo. OK
        * ./ssh2 127.0.0.1 tom '*****' 'cat xulu; cat mbox; cat mbox' 1 100 >foo
> display error messages
> records _partly_ mbox in foo. BAD
        * ./ssh2 127.0.0.1 tom '*****' 'cat xulu; cat mbox; cat xulu' 1 >foo
        or * ./ssh2 127.0.0.1 tom '*****' 'cat mbox' 1 >foo
> stops while reading stderr. BAD
        * ./ssh2 127.0.0.1 tom '*****' 'cat xulu' 1 >foo
> display error and quit. OK
        * ./ssh2 127.0.0.1 tom '*****' 'cat mbox' >foo
> records mbox in foo. OK

So, have someone a good method to read both completely stdout and
stderr?

-- 
Thomas Harding


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel

Received on 2007-08-05