Hello MacPerl gurus and gurettes,


I'm running MacPerl 5.6.1r2 under OS 8.6, and having trouble downloading large (2+ Mb) binary files using Net:FTP. I've given MacPerl 40 Mb of RAM in the finder, but the file transfer stops at around 1.5 Meg and my mac freezes up (no out-of-memory error, but a lockup of my system requiring a hard reboot). If I increase MacPerl's memory allocation to 80 Mb, I can get a bit further on the transfer, but something is clearly wrong here.

Here is a sample that shows what I'm trying:
# ---- start sample FTP code ----
use Net::FTP;
$ftpServerURI="192.168.128.19";
$userName="sml";
$password="xyzzy";
$getFolder="test/";
$debug=1;
$currentDBFile = "BigBinaryFileTest";

unless( $ftp = Net::FTP->new( $ftpServerURI, ( Debug => $debug ) ) ) {
die( "ftp failed - can't connect to " . $ftpServerURI );
}
$ftp->login( $userName, $password );
$ftp->hash( 1, 1024*32 );
$ftp->binary();
$ftp->get( $getFolder . $currentDBFile, "test_download" ) or die( "Quitting ... no file found.\n" );
$ftp->quit;
# ---- end sample FTP code


...from which I get about 50 or 100 hash marks (#'s) printed, depending on the RAM allocation for MacPerl, before a system freeze.

Just for grins (right!), I tried using an LWP::UserAgent to accomplish this instead. Here's another sample code fragment (pretty much ripped off directly from the lwpcook.pod):

# --- start sample LWP code ----
  use LWP::UserAgent;
  $ua = LWP::UserAgent->new;

 #does this use TEXT transfer?
  my $req = HTTP::Request->new(GET =>
                'ftp://sml:[EMAIL PROTECTED]/test/BigBinaryFileTest');
  $res = $ua->request($req, "download_test_lwp");
  if ($res->is_success) {
     print "ok\n";
  }
  else {
     print $res->status_line, "\n";
  }
# ---- end sample LWP code

I get pretty similar results (meaning my Mac freezes up several seconds into the download), which makes me think both LWP and FTP tap some lower-level library on the Mac that might be the problem...?

Both of these code samples work fine for me on a Windoze box running ActiveState perl.

FWIW, I've tried applescript'ing Fetch 3.0.3 from MacPerl, but the AE syntax for downloading doesn't seem to allow automatically specifying the save-to file name, so I get Fetch's file-save dialog popping up and waiting for input. For this application, I need the FTP transfer to run unattended. Oh, and Fetch has absolutely no problem doing the download if there is a user around to press the buttons.

Anyone out there still trying to make perl run on older Mac's and can help ?

TIA,

S. Maxson




Reply via email to