my($out,$err) = $ssh->cmd($cmd); print "the output is $out\n" #### #!/usr/bin/perl use strict; use warnings; use diagnostics; use Net::SSH::Perl; my $host = 'host'; my $user = 'user'; my $password = 'password'; my $cmd = 'ls -l'; my $ssh = Net::SSH::Perl->new( $host, port => 22, protocol => 2, debug => 1 ); $ssh->login( $user, $password ); my ( $stdout, $stderr, $exit ) = $ssh->cmd($cmd); print $stdout, "\n";