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



Sisyphus wrote:
"rna8arnold" <rna8arnold@xxxxxxx> wrote in message
news:1140129582.622597.277610@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

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
ftp->get().

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?


code:

# 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) {
$ftp->quit;
&dienice ("Can't login to $host: $! $?\n");
}

# go to the directory containing the file
$ftp->cwd($directory) or $newerr=1;
if ($newerr) {
$ftp->quit;
&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
$ftp->quit;



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
'C:\path\file.ext'.

Cheers,
Rob



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

Tom Wyant
.



Relevant Pages

  • Re: Same Internal Server Error from last two days
    ... I am trying to run a Hello World Perl Script in Apache 2.2. ... But its constantly giving me Internal Server Error.The script ... # have to place corresponding `LoadModule' lines at this location so the ...
    (perl.beginners)
  • Re: Same Internal Server Error from last two days
    ... I am trying to run a Hello World Perl Script in Apache 2.2. ... But its constantly giving me Internal Server Error.The script Runs perfectly fine from the command prompt. ... # This is the main Apache HTTP server configuration file. ... LoadModule actions_module modules/mod_actions.so ...
    (perl.beginners)
  • Same Internal Server Error from last two days
    ... I am trying to run a Hello World Perl Script in Apache 2.2. ... But its constantly giving me Internal Server Error.The script ... # have to place corresponding `LoadModule' lines at this location so the ...
    (perl.beginners)
  • Re: Regarding a selection for mobile code/scripting language
    ... Client Side scripting, so the server can send script commands to the client. ... I decided they should be scripted and mobile code. ...
    (Vuln-Dev)
  • Re: HTTPSConnection script fails, but only on some servers (long)
    ... (HTTP/CONNECT + switch to HTTPS) ... wget and my python script. ... >>The python script works with server A, ... the problem seems to depend on both the client ...
    (comp.lang.python)