#!/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);