Re: [Ssh-sftp-perl-users] quick question with regard to exec, take 2
Brought to you by:
dbrobins
|
From: Thierry C. <thi...@gm...> - 2009-04-04 21:27:58
|
Jeremy Kitchen a écrit :
> Thierry CHICH wrote:
>
>> Jeremy Kitchen a écrit :
>>
>>> I'm trying to write a quick program which will execute a series of
>>> commands on the remote system and get each individual exit status back
>>> from the commands.
>>>
>>> It appears the way to go about doing this is to create a new channel,
>>> exec, get the exit status, destroy the channel, exec, get the exit
>>> status, etc.
>>>
>>> However, I *also* want to grab the output of these commands (stdout and
>>> stderr) in real time, so I'm trying to use poll.
>>>
>>> Now, I could be going about this completely the wrong way. If I am,
>>> please let me know :)
>>>
>>>
>>>
>> I don't know if you are going the wrong way. However, I don't
>> understand why you are not using
>> ( $out, $err, $exit ) = $ssh->cmd( "$cmd" ); ?
>>
>> You can even execute a complete script shell using sthis syntax:
>>
>> ( $out, $err, $exit ) = $ssh->cmd( "bash", "$myscrypt" );
>> Isn't it simpler ?
>>
>>
>
> I'm not using Net::SSH::Perl, I'm using Net::SSH2. Net::SSH::Perl can't
> connect to several of our machines, but Net::SSH2 can. Also, using
> Net::SSH2's ->cmd method still doesn't give me 'real time' reading of
> the outputs. I *do* want to do something like what ->cmd does
> eventually, for really stupid easy stuff where we don't really care
> about the output until it's done (or commands that are *really* quick)
> but in the mean time I'm trying to get the realtime stuff working.
>
> -Jeremy
>
Ok. I should have seen that the syntax was not coming form the
Net::SSH::Perl
I have not use Net::SSH2 as you have : for me, there is a big lack to
the libssh2 library,
and it is the lack of ssh-agent support.
So it could be a stupid suggestion, but have you try to put
$channel->blocking(0);
at the beginning of your script ?
I remember I had problem without this line.
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Ssh-sftp-perl-users mailing list
> Ssh...@li...
> https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users
>
|