use Getopt::Std; use Net::SSH::Perl; &getopts('h:u:p:'); &Usage( ) unless( defined($opt_h) && defined($opt_u) && defined($opt_p) ); $ssh = Net::SSH::Perl->new( $opt_h, port => 22 ); $ssh->login( $opt_u, $opt_p ); while( 1 ) { print "$opt_h\> "; $cmd = ; $cmd =~ s/^\s+|\s+$//g; last if( $cmd eq "" ); ($stdout, $stderr, $exit_code) = $ssh->cmd($cmd); if( $exit_code ) { print $stderr; } else { print $stdout; } } exit( 0 ); sub Usage { print “Usage: $0 -h -u -p \n”; exit( 0 ); } # end of Usage