Help Using Expect
From: Jim (nep777_at_yahoo.com)
Date: 06/30/04
- Next message: ddtl: "Re: Getting to variables contained in a typeglob referenced by a scalar."
- Previous message: Ala Qumsieh: "Re: syntax?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Jun 2004 11:46:21 -0700
Hi
I am using expect to automate sftp file transfers. It works fine for
files under 1MB. However it dies when It tries to grab big files. It
seems to always die at 1.4MB. If I sftp manually, there is never a
problem. Also, if I run the script to connect to the server, then go
interactive (by using expect's interactive routine) it works. I have
tried everything from the expect.pm documentation. Here is the
relevant code.
Thanks for any suggestions
---
#!/db/app/perl/bin/perl -w
use Expect;
$cmd = '/appl/uas/ssh/bin/sftp user@host';
$pw = 'mypassword';
$lcd = '/temp/raw_downloads';
# switch to local dir where the xferd files should go
chdir $lcd;
# spawn the sftp program
my $sftp = Expect->spawn($cmd) or die "Can't spawn cmd: $!";
# $sftp->log_stdout(0);
# wait 10 seconds for password prompt:
unless ( $sftp->expect(10, -re , '.*assword:') ) {
print "timed out or something else went wrong\n";
exit;
}
print $sftp "$pw\r";
# wait for sftp shell prompt:
unless ( $sftp->expect(10, -re , 'sftp>') ) {
print "timed out or something else went wrong\n";
exit;
}
# cd to the remote server dir to grab the files from
$sftp->send("cd /u10/seatab\r");
### IF I GO INTERACTIVE HERE, IT WORKS ######
# $sftp->interact();
# wait for the next shell prompt:
unless ( $sftp->expect(10, -re , 'sftp>') ) {
print "timed out or something else went wrong\n";
exit;
}
# grab the files
###### THIS IS WHERE IT DIES. #####
$sftp->send("mget TRANSACT*\r");
$sftp->soft_close();
...............
- Next message: ddtl: "Re: Getting to variables contained in a typeglob referenced by a scalar."
- Previous message: Ala Qumsieh: "Re: syntax?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|