Hi,
I have a simple Expectperl test program from "Perl
Cookbook". It feeds my password to do an "scp". In
sudo it works and did scp a file. But as a user, e.g.
myself, the same program timed out for the password
prompt:
------------------------------------------------------
my $cmd = "/usr/local/bin/scp $uid\@$frhost:$srcfile
$tmpdir/.";
my $command = Expect->spawn($cmd) or return "Couldn't
start program: $!\n";
$command->log_stdout(0);
unless ($command->expect(10, "$uid\@$frhost\'s
password:")) {
print "Waiting for password prompt timed
out.\n";
exit;
}
print $command "$pswd\r";
$command->soft_close();
$command->hard_close();
-------------------------------------------------------
The 1st run:
sudo ./test-expect.pl guoben host /tmp/foo passwd
The 2nd run:
./test-expect.pl guoben host /tmp/foo passwd
What could be the problem?
Thanks!!
Guoben Li
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
|