#!/usr/bin/perl use warnings; use strict; use Net::FTP; $ftp = Net::FTP->new("some.host.name", Debug => 0); $ftp->login("anonymous",'-anonymous@'); my $timeout = 60; my $time; eval { local $SIG{ALRM} = sub { die "timeout!" }; alarm $timeout; $ftp->cwd("/pub"); $ftp->get("that.file"); $ftp->quit; $time = alarm 0; } if ($@) { if ( $@ =~ /timeout/ ) { #do something } else { #do something else for other failures } } else { print "External call finished in " . ( $timeout - $time ) . " seco +nds\n"; }
In reply to Re^3: How to FTP with Timeout?
by zentara
in thread How to FTP with Timeout?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |