Help Using Expect

J

Jim

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();

................
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top