in reply to Net::SSH::Perl Realtime output

You can do it using the register_handler function that Net::SSH::Perl provides.

For example

#!/usr/bin/perl -w use Net::SSH::Perl; use strict; my $host = "localhost"; my $username = "anthski"; my $password = "somepassword"; my $ssh = Net::SSH::Perl->new($host, debug => 0, protocol => '2'); my $command = "tail -f /var/log/messages"; my $loginStatus = $ssh->login($username,$password); my $stdout; my $stderr; my $exit; $ssh->register_handler("stdout", sub { # This will match any packets which are stdout and print them +to the screen # You could do something smarter with them if you wanted my($channel, $buffer) = @_; my $str = $buffer->bytes; print "$str\n"; }); ($stdout,$stderr,$exit) = $ssh->cmd($command);

As per my comment in the code, you can then do whatever you want with the output of your command.

cheers,
Anth

Replies are listed 'Best First'.
Re^2: Net::SSH::Perl Realtime output
by shooter (Novice) on Sep 02, 2005 at 09:32 UTC
    Anth,

    Cheers,that saved me alot more heartache and is much appreciated. Needless to say it worked a treat.