[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Net::FTP Problems with Proxies

At 6:08 PM +0200 6/1/99, Matt Henderson wrote:
>My Net::FTP-based script works perfectly within our local network; however,
>it fails as soon as I try to FTP to a host outside our FTP proxy.
>Here's a code sample:
>    # Create a new FTP session object
>    $ftp = Net::FTP-new($host,
>        Timeout=>30,
>        Firewall=>$proxy,
>        Debug=>1) or die("Could not connect: $@\n");
>It never gets past this statement. (Also, it doesn't seem to die after 30

I can't help you with the ftp proxy, but I have run into
problems with the timeout not working.  Here's my workaround:

$SIG{ALRM} = \&timesup;
                              # using an eval to trap
eval {                        # &timesup's die (see below)

    alarm(180);               # three minute time limit
    $ftp = Net::FTP->new(
        "timeout" => 30);
    alarm(0);                 # reset alarm if it works

                              # die anyway -- you could do
                              # something more interesting
die "ftp timed out:$!\n"      # here if the ftp fails.
    if ($@ =~ /timesup/ || ! ref($ftp) );

sub timesup {die "timesup";}


I should note, I left the "timeout" => 30 in hoping to
prove to myself that the ftp timeout worked as intended.
Instead I proved to myself that it doesn't (or I don't
have the right syntax  8^).  Anyway, the alarm() worked
for me.

Hope it helps.

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org