phillipewu has asked for the wisdom of the Perl Monks concerning the following question:
I am trying the module Net::SSH::Expect to login to a UNIX machine using ssh.
I know that I can set up the hosts as "trusted" hosts but the site I am working at does not allow this. Also to get to the target machine I need to go via a number of intermediate servers. I was hoping to use the module Net::SSH::Expect to log me in.
I have set up a simple trial but the "interact" part does not work - it hangs.
Can someone tell me how to fix it?
===========================================================
use Net::SSH::Expect; my $ssh = Net::SSH::Expect->new ( host => "utility", user => 'vzblk0', raw_pty => 1 ); # Start the ssh process $ssh->run_ssh() or die "SSH process couldn't start: $!"; # you should be logged on now. Test if you received the remote prompt: $output=$ssh->read_all(2); print($output); if ($output =~ />\s*\z/) {die "where's the remote prompt?"}; # - now you know you're logged in - # # disable terminal translations and echo on the SSH server # executing on the server the stty command: $ssh->exec("stty raw -echo"); $output = $ssh->exec("who"); print ($output); $output = $ssh->exec("uname -a"); print ($output); $exp=$ssh->get_expect(); $exp->interact;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Module Net::SSH::Expect - Cannot interact
by moklevat (Priest) on Apr 30, 2008 at 13:45 UTC | |
by phillipewu (Initiate) on Apr 30, 2008 at 23:12 UTC | |
by Khen1950fx (Canon) on May 01, 2008 at 10:07 UTC |