From: Powell, D. <DP...@ep...> - 2009-09-01 15:31:04
|
Hi: We are using perl v5.8.3 (with 8 registered patches) on HP-UX (B.11.23 ia64 architecture), and we're trying to use Expect to automate connection to a remote sftp server. For our testing, I am using Expect to send the password for us. For production, we have already sent public key credentials to the remote server, so there is no need to send a password -- authentication is done via public key. The following code snippet seems pretty standard, but it _always_ results in Expect returning a timeout condition: my $prompt = 'sftp>'; $ftp = new Expect; $ftp->raw_pty(1); $ftp->spawn("sftp", 'use...@xx...') or die "ERROR #1\n"; $ftp->expect($timeout, [qr{^Connecting to .*$} => sub {$ftp->exp_continue;}], [qr'password: ' => sub{$ftp->send("xxxxxxxxx\n");}], [timeout => sub { $okay = 0; $ftp->soft_close(); print "TIMEOUT\n"; }], $prompt ); die "ERROR: " . $ftp->error ."\n" if $ftp->error; When we run the script, the conversation looks like: use...@xx...'s password: TIMEOUT ERROR: -1 shell returned 22 I can confirm that the sftp> prompt appears before the TIMEOUT message is printed, so at that point we are connected to the remote server. Now, if I remove the timeout=> block, everything works fine. No timeout condition is called, and the rest of the script continues as normal. Is there a problem with the way the timeout block is coded, or is something wrong with the way Perl::Expect works on HP-UX? Any suggestions would be most appreciated. Best Regards, Dean Powell Edmonton, Canada This email message, including any attachments, is for the intended recipient(s) only, and contains confidential and proprietary information. Unauthorized distribution, copying or disclosure is strictly prohibited. If you have received this message in error, or are obviously not one of the intended recipients, please immediately notify the sender by reply email and delete this email message, including any attachments. Thank you. |