salva has asked for the wisdom of the Perl Monks concerning the following question:
I have written an script that uses Expect to perform password authentication on a SSH connection:
and it works, but the Password: prompt still gets printed to the console. Is there any way to eliminate it?# initialize an Expect object: my $conn = Expect->new; $conn->raw_pty(1); # spawn a new SSH process: $conn->spawn('/usr/bin/ssh', -l => $user, $host, -s => 'sftp') or die $errstr; # wait for the password prompt: $conn->expect($timeout, "Password:") or die "Password not requested as expected"; $conn->send("$passwd\n"); # SSH echoes the "\n" after the password, remove it from the stream: $conn->expect($timeout, "\n");
The full source code for the script is available from here
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Expect & SSH
by Fletch (Bishop) on Apr 25, 2007 at 01:36 UTC |