Net::FTP crashes on ftp->get()

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

 I am having trouble getting my cgi script using Net::FTP to get a zip
file from a remote server (Microsoft server) into the server where the
script resides (UNIX freeBSD/Apache server). The browser ends up with a
blank page, because the cgi script seems to crash whenever we get to

I used Komodo to test this script and it worked fine from my WindowsXP
PC. But when the script is uploaded to the website server (UNIX
freeBSD/Apache server) it fails to work properly.

Any ideas what the problem could be?


# setup ftp object
   $ftp = Net::FTP->new($host, Timeout=>240, Debug => 1) or
   dienice ("Can't ftp to $host: $!\n");

   # Login to the ftp site as anonymous
   $ftp->login("anonymous") or $newerr = 1;
   if ($newerr) {
      &dienice ("Can't login to $host: $! $?\n");

   # go to the directory containing the file
   $ftp->cwd($directory) or $newerr=1;
   if ($newerr) {
      &dienice ("Can't change to $directory: $!\n");

   $ftp->binary(); # since we are transferring a zip file use binary
instead of ascii

   #Get zip archive and place it on local server

   $ftp->get($filename, $filename) or $newerr=1;
   if ($newerr) {
      $success = $false; # failed file probably doesn't exist
   else {
      $success = $true; # file was successfully transferred

   $transferred_file = $filename; #save pathname of transferred file
   #disconnect from the ftp site

Re: Net::FTP crashes on ftp->get()

Quoted text here. Click to load it

Could it be that the local (Unix) machine is unable to copy $filename to the
location specified by $filename ? Perhaps a permissions issue .... or
perhaps the Unix machine just can't cope when $filename is something like


Re: Net::FTP crashes on ftp->get()

Sisyphus wrote:
Quoted text here. Click to load it

What error is FTP returning? It does not come back in $!, as your script
seems to assume.

Tom Wyant

Site Timeline