#!/usr/bin/perl -w use strict; use Net::SSH2; my $buflen = 100; my $buf = '0' x $buflen; my $ssh2 = Net::SSH2->new(); $ssh2->connect('10.1.1.85','22') or die; #$ssh2->debug(1); $ssh2->auth_publickey('root','pub.pub','priv.ppk','toor') or die "Unable to login $! \n"; my $chan1 = $ssh2->channel(); $chan1->blocking(1); $chan1->exec('df'); $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; system ("pause");