senor_fjord has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to use Expect to log into a series of machines to run uptime on them. I get to the password prompt and then when I send my password it just hangs and doesn't execute the command. I have tried sending the password string by itself, ending in a \n, a \r, and a \r\n to no avail. Below is the code:
$ssh_cmd = Expect->spawn("ssh $host uptime"); unless ($ssh_cmd->expect(3, "password:")) { print "ssh error"; print $ssh_cmd "password";
Thanks in advance for any insights.

Replies are listed 'Best First'.
Re: using Expect with ssh
by Anonymous Monk on Jun 22, 2002 at 15:32 UTC
    you can have an ssh key on the remote server (using ssh-keygen) so that only that you can limit ony one computer to connect.. Then you wouldn't have to worry about the password. (btw I don't think storing the password in a script is a good idea.)
      I am having the same problem. I need to connect to 3 machines using ssh then prompt for password then go to cd /file then start program then have the 3 machines logs come up. Can you help with this.