use Net::SSH2; use warnings; use strict; my $buflen = 100; my $buf = '0' x $buflen; my $ssh2 = Net::SSH2->new(); $ssh2->connect('192.168.0.3') or die; $ssh2->auth_password('username','password') or die "Unable to login $! \n"; my $chan1 = $ssh2->channel(); $chan1->blocking(1); $chan1->exec('echo $PATH'); $chan1->read($buf, $buflen); print "BUF: ", $buf, "\n"; $chan1->close; my $chan2 = $ssh2->channel(); $chan2->blocking(1); $chan2->exec('echo $HOME'); $chan2->read($buf, $buflen); print "BUF: ", $buf, "\n"; $chan2->close;