Wiggins d'Anconia wrote:
Ramprasad A Padmanabhan wrote:

Hi all,
  I have a perl Expect script that install rsa keys for ssh auto login.
When I run the script on command line it works fine.
Now when I run it inside a CGI the script simply gets stuck.  I can see
from the from the SSH server and also the expect logs that the login is
happenning. But After login nothing happens :-(
The commands I give to append the authorized_keys2 file are not executed
at all.


Are the keys readable by the web server user? Sounds like a permissions
problem.


The problem is not with permissions. Actually this is the part script where it hangs


......
# $exp is the expect object
$exp->expect(10,
                 '-re' , $prompt , \&inter,
'-re',"password:",sub {}) or die "Couldnt get pass prompt\n";
$exp->send("$password\r");
$exp->expect(10, -re , $prompt) or die "Couldnot login\n";

# Until here it is fine. I can see in the ssh logs that login has happened
# The foll commands work if run on commandline only
$exp->raw_pty(1);
$exp->send("\r");
my $cmd = "lynx -source http://192.168.2.32/rsakey.txt >> ~/.ssh/authorized_keys2\r";
$exp->send($cmd);
$exp->send("\r");
$exp->send("sleep 1 && exit\r");

# The next step is compulsory else nothing works even on command line
#        I dont understand why
$exp->interact();
exit(0);

###############################
I can attach my entire script if necessary



Thanks
Ram





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to