in reply to Correct way to use Net:SSH2 module
I use:
sub sshSendCommand { my ($self, $cmd, $pollTime) = @_; my $chan = $self->{ssh}->channel(); my $log = ''; my $timeDelta = sprintf "%4d:", time() - $self->{startTime}; $pollTime ||= 500; print "$timeDelta ssh: <$cmd> (poll time: $pollTime)\n"; $chan->exec($cmd); my @poll = {handle => $chan, events => ['in']}; while ($self->{ssh}->poll($pollTime, \@poll)) { if ($poll[0]{revents}{channel_closed}) { print "$timeDelta channel closed\n"; last; } next if !$poll[0]{revents}{in}; my $buff; $log .= $buff while $chan->read($buff, 1024); next; } print "$log\n$timeDelta ssh command complete\n"; return $log; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Correct way to use Net:SSH2 module
by MikeKulls2 (Novice) on Mar 21, 2013 at 04:04 UTC | |
by salva (Canon) on Mar 21, 2013 at 09:30 UTC | |
by MikeKulls2 (Novice) on Mar 21, 2013 at 22:30 UTC | |
by salva (Canon) on Mar 22, 2013 at 08:11 UTC | |
by MikeKulls2 (Novice) on Mar 25, 2013 at 21:40 UTC | |
|