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

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

am 16.02.2006 23:39:42 von rna8arnold

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;

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

am 17.02.2006 01:45:27 von Sisyphus

"rna8arnold" wrote in message
news:1140129582.622597.277610@o13g2000cwo.googlegroups.com.. .
> 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

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

am 17.02.2006 01:54:08 von unknown

Sisyphus wrote:
> "rna8arnold" wrote in message
> news:1140129582.622597.277610@o13g2000cwo.googlegroups.com.. .
>
>>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