graq has asked for the wisdom of the Perl Monks concerning the following question:
- Graqpackage MyWrapper::FTP; use vars qw( @ISA ); @ISA = qw( MyWrapper ); require Net::FTP; use strict; my $FTP_TIMEOUT = 60; sub create_connection { my ($self, $connection_string) = @_; $connection_string =~ /^(\w+):(\S+)@(\S+)$/; my ($login,$password,$host) = ($1,$2,$3); my $ftp; eval { $login && $password && $host or die "Can't parse connection string '".$self->connection +_string."'\n"; $ftp = new Net::FTP($host, (Timeout=>$FTP_TIMEOUT) ); die "FTP: failed to connect to $host: $!\n" if not $ftp; $ftp->login($login, $password) or die "FTP: Can not login to $login\@$host\n"; $ftp->binary; }; if ($@) { # Do some logging. } $self->set('host', $host); return $ftp; } sub send_file { my ($self, $file, $outfile) = @_; my $host = $self->get('host'); my $ftp = $self->ftp; my $workfile; $workfile = 'test.tst'; # Various unrelated decisions # on what $workfile is occur here. if( $ftp->put($file, $workfile) )# <--- This is where it apparentl +y hangs. { # Log some intermediary success. if( $ftp->rename($workfile,$outfile) ) { # Log some success. } else { die( "FTP: $file -> $host:$outfile - FAILED: $!\n" ); } } else { die( "FTP: $file -> $host:$outfile - FAILED: $!\n" ); } } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::FTP Wrapper: TCP problem
by Brovnik (Hermit) on May 31, 2001 at 15:07 UTC | |
by graq (Curate) on May 31, 2001 at 15:58 UTC | |
|
Re: Net::FTP Wrapper: TCP problem
by petral (Curate) on May 31, 2001 at 16:42 UTC | |
by graq (Curate) on May 31, 2001 at 17:14 UTC | |
by petral (Curate) on May 31, 2001 at 18:38 UTC |