
sonia93
New User
Dec 13, 2007, 12:18 AM
Post #1 of 2
(184 views)
|
|
working on perl expect
|
Can't Post
|
|
Hi , I am using expect in perl script to log in remotely to another machine. The code is something like this : $exp = new Expect(); $cmd = ssh username1@hostname1 $exp->spawn($cmd); #login and interact $exp->expect(20, [ qr/\(yes\/no\)\?\s*$/ => sub { my $exp=shift; $exp->send("yes\n"); exp_continue; } ], [ $prompt => sub { my $exp=shift; $exp->send("$password\n"); } ]) or die "NORMAL LOGIN FAILED\n"; After this I am trying to get on to root on host machine as in order to execute one command , it needs root authority , hence am doing : $exp->send(" su root\n") || die "SU command failed"; this particular statement is failing repeatedly. After logging as root I want to send another command to generate the ssh key pair like $exp->send("ssh-keygen -t rsa\n"); But its not logging in as root. Is there something like one cannot log in as root using any other remote script like perl expect ? I really need help in this. Thanks a lot !! Sonia
|