#!/usr/bin/perl
use strict;
use warnings;
use Net::SSH2;
my $ssh2 = Net::SSH2->new();
$ssh2->connect('hostname', 22)
or $ssh2->die_with_error;
my $chan = $ssh2->channel()
or $ssh2->die_with_error;
$chan->blocking(0);
$chan->exec("ls ./")
or $ssh2->die_with_error;
while (<$chan>){ print }
print "exit status: " . $chan->exit_status . "\n";
$ssh2->disconnect();
####
no libssh2 error registered at /home/tinyos/perl5/lib/perl5/x86_64-linux-gnu-thread-multi/Net/SSH2.pm line 54.
####
my @output = `ssh -p 22 username "ls"`;
chomp @output;
print Dumper \@output;