boboson has asked for the wisdom of the Perl Monks concerning the following question:
sub sendFile { # application object my $self = shift; # load template files my $tmpl = $self->param('info' => $self->load_tmpl ('info.phtml')); # create an ftp object my $ftp = Net::FTP->new("XXX.XX.XX.XXX", Debug => 1, Port => 21) or di +e "Cannot connect to host: $@"; # login to the ftp server $ftp->login("user",'pass') or die $ftp->message; # get root directory $ftp->cwd() or die $ftp->message; # get the filename my $filename = "dir+filename"; # check if file exist if(-e $filename){ # send file in binary mode $ftp->binary; # send a file to the remote server $ftp->put($filename) or die $ftp->message; } # quit the ftp connection $ftp->quit; # output return $tmpl->output; } sub deleteFile { # application object my $self = shift; # load template files my $tmpl = $self->param('info' => $self->load_tmpl ('info.phtml')); # create an ftp object my $ftp = Net::FTP->new("XXX.XX.XX.XXX", Debug => 1, Port => 21) or di +e "Cannot connect to host: $@"; # login to the ftp server $ftp->login("user",'pass') or die $ftp->message; # get root directory $ftp->cwd() or die $ftp->message; # get the filename my $filename = "filename"; # delete a file to the remote server $ftp->delete($filename); # quit the ftp connection $ftp->quit; # output return $tmpl->output; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Print debug information from Net::FTP
by bowei_99 (Friar) on Apr 01, 2006 at 21:44 UTC | |
by boboson (Monk) on Apr 02, 2006 at 14:17 UTC | |
|
Re: Print debug information from Net::FTP
by bowei_99 (Friar) on Apr 01, 2006 at 18:42 UTC | |
by boboson (Monk) on Apr 01, 2006 at 18:58 UTC | |
by bowei_99 (Friar) on Apr 01, 2006 at 20:18 UTC | |
by boboson (Monk) on Apr 01, 2006 at 20:52 UTC |