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; #### use warnings; use strict; use Net::SSH2; print "Hostame: "; my $host = ; print "Username: "; my $user = ; print "Password: "; my $pass = ; my $ssh2 = Net::SSH2->new(); $ssh2->connect($host) or die "Unable to connect $host $@ \n"; $ssh2->auth_password($user,$pass) 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;