[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to wait on a channel for data with channel_poll()


have you checked the exec example?

Sounds a bit strange since ssh_channel_read() is exactly what I am 
using (for stdout and stderr) and it works fine. I loop as long as it 
returns > 1. If it is 0 I know there is no more data and if it is < 1 
there was an error. Has been working fine so far. I am using the 
latest 0.5 version from the reposiotry though.

> Hi,
> 
> In my program, I call channel_request_exec() to execute a remote command,
> and right after that, call channel_poll() to check if there are any data
> back (The command will get some info from the remote host). But I found,
> channel_poll() always return 0 which means no data available, but the remote
> command does output something, is it a timing issue? I mean it will take
> some time for the command to collect info in the remote host and print them
> out, so before anything printed, channel_poll() will always return 0, right?
> 
> So how can I wait on a channel for any incoming data?
> 
> And another question is how I can know all the data has been received? Why I
> ask this question is, if I change my program not to call channel_poll(),
> just call channel_read() to read data in a while loop, I found even the
> remote command is done, and all its output has been received, channel_read()
> still blocks there, so I can not break out from that while loop.
> 
> 
> Thanks,
> Qian
> 



Follow-Ups:
Re: How to wait on a channel for data with channel_poll()Qian Zhang <zhq527725@xxxxxxxxx>
References:
How to wait on a channel for data with channel_poll()Qian Zhang <zhq527725@xxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org