From: Bryan C. <co...@od...> - 2007-03-15 22:40:35
|
Thanks, Austin! I copied your script verbatim, and it works. However, it doesn't make any difference whether I include the space after the prompt or not. It works in either case. ( Well, the space is included in $sftp->before(), but that's beside the point. ) So now I'll start turning your script into mine incrementally until it breaks. I'll let you know what I discover. Bryan=20 -----Original Message----- From: Austin Schutz [mailto:te...@of...]=20 Sent: Thursday, March 15, 2007 2:40 PM To: Bryan Cox Cc: Bradford Ritchie; exp...@li... Subject: Re: [Expectperl-discuss] Expect.pm & sftp On Wed, Mar 14, 2007 at 02:27:17PM -0700, Bryan Cox wrote: > Here's an update: > =20 > I've tried sftp, ftp, and rlogin. All fail in the same way: > =20 > -> spawn id(4): Does `' > -> match: > -> pattern #1: -re `(?-xism:ame.*:)'? No. > -> pattern #2: -re `(?-xism:assword:)'? No. > -> pattern #3: -re `(?-xism:ftp>)'? No. > -> pattern #4: -re `(?-xism:(\n)|(\r))'? No. > -> Waiting for new data (10 seconds)... > -> TIMEOUT >=20 This may be failing because of a race condition. You are not waiting for a space after 'sftp>'. I have a simple script I was able to use to get a listing of files from sftp, so I don't think sftp itself is doing anything odd: #!/usr/bin/perl use Expect; # usage: test.pl <[username@]host> <password> $sftp =3D Expect->spawn('sftp ' . $ARGV[0]); $sftp->exp_internal(1); $sftp->expect(10, 'ord: '); print $sftp $ARGV[1]."\r"; $sftp->expect(10, 'sftp> '); print $sftp "ls\r"; $sftp->expect(10, 'sftp> '); print "Files:" . $sftp->before(); It's important to make sure you have received all the output from the remote host before sending it anything. It may flush its buffers before reading, thereby dumping whatever you thought you sent it. Austin |