use warnings; use strict; use Net::SSH2; my $ssh2 = Net::SSH2->new(); $ssh2->connect("hostname") or die "Unable to connect to host $@ \n"; $ssh2->auth_password('username','password') or die "Unable to login $@\n"; my $chan=$ssh2->channel(); $chan->shell(); print $chan "ifconfig\n"; print "LINE : $_" while <$chan>; print $chan "top\n"; print "LINE : $_" while <$chan>; $chan->close;