#!/usr/bin/perl use warnings; use strict; use Net::SSH::Perl; my $srvr = "testserver"; my $username = "test"; my $oldpasswd = "test"; my ($stdout, $stderr, $exit); my $cmd = ('passwd'); my $ssh = Net::SSH::Perl->new($srvr, protocol => 2, debug => 1); $ssh->register_handler("stderr", sub { my($channel, $buffer) = @_; print "** Standard Error - I received this:\n", $buffer->bytes; }); # This trigger works perfectly # $ssh->register_handler("stdout", sub { my($channel, $buffer) = @_; print "** Standard Out - I received this:\n", $buffer->bytes; }); $ssh->login($username, $oldpasswd); $ssh->cmd($cmd); print "** Ran Command ". $cmd ."\n";