bala_999 has asked for the wisdom of the Perl Monks concerning the following question:
#!/bin/perl use Expect; $host = xxxxx; $user = yyyyy; $pw = shift; #--- CONFIGURATION --------------------------------------------------- +--------# $cmd = "ssh -l $user $host"; $prompt = "[Pp]assword"; #--- START SSH LOGIN SEQUENCE ! -------------------------------------- +--------# $exp = new Expect(); $exp->log_file("SSHLOGFILE.txt"); $exp->raw_pty(1); $exp->spawn($cmd); $exp->expect(10, [ qr/\(yes\/no\)\?\s*$/ => sub { $spawn->send("yes\n"); + exp_continue; } ], [ $prompt => sub { $_[0]->send("pwd\n"); } ]); Here im unable to switch to super user login $exp->send("su - root\n"); $exp->expect(10, [ $prompt => sub { $_[0]->send("pwd\n"); } ]); $exp->close();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: ssh using expect
by tirwhan (Abbot) on Dec 04, 2007 at 18:23 UTC | |
by bala_999 (Novice) on Dec 04, 2007 at 18:34 UTC | |
by tirwhan (Abbot) on Dec 04, 2007 at 19:10 UTC | |
by Anonymous Monk on Jan 12, 2012 at 15:05 UTC | |
|
Re: ssh using expect
by moritz (Cardinal) on Dec 04, 2007 at 18:18 UTC | |
by bala_999 (Novice) on Dec 04, 2007 at 19:30 UTC |