Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Error ftping file with Net::FTP

by thanos1983 (Parson)
on Aug 16, 2017 at 14:55 UTC ( [id://1197506]=note: print w/replies, xml ) Need Help??


in reply to Error ftping file with Net::FTP

Hello Anonymous Monk,

Try something like this:

#!/usr/bin/perl use CGI; use strict; use warnings; use Net::FTP; use feature 'say'; my $cgi = CGI->new(); my $file = $cgi->param( 'upload' ) || 'test.pl'; say do_ftp($file); sub do_ftp { my ($filename) = @_; return unless $filename ; } __END__ $ perl ftp.pl test.pl

We do not have the full code but I assume my $file = $cgi->param( 'upload' ) || ''; that you are passing an empty string here right? I have alter the code in two points. Observe the () in the subroutine also.

I would recommend to use module Net::SFTP::Foreign. Similar question with samples of working code(s) Generate temporary file and FTP upload.

Hope this helps, BR.

Seeking for Perl wisdom...on the process of learning...not there...yet!

Replies are listed 'Best First'.
Re^2: Error ftping file with Net::FTP
by Anonymous Monk on Aug 16, 2017 at 15:06 UTC
    I was missing the "()" in the sub, thanks for pointing that out!
Re^2: Error ftping file with Net::FTP
by Anonymous Monk on Aug 16, 2017 at 15:54 UTC
    Is there a bug in Net::FTP?
    I am checking if the file exists using this command:
    my @check = $ftp->ls("$filename"); I am getting an error:
    Can't use an undefined value as a symbol reference at /Net/FTP/datacon +n.pm line 54.

    Any suggestions?
        Yes, that seems to fix the issue:
        my $ftp = Net::FTP->new($host, Debug => 0, Passive => 0) or die "Could not connect to '$host': $@";

        Thank you!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1197506]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2024-04-24 06:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found