Beelzebub has asked for the wisdom of the Perl Monks concerning the following question:

HI, I am trying to upload an image from one server to another. The code I am using looks like this =>
my $ftp_1 = Net::FTP->new("server.one.com", Debug => 1, Passive => 1, +Timeout => 500) or die "connect failed: $!"; my $ftp2 = Net::FTP->new("server.two.com", Debug => 1, Passive => +1); $ftp1->login("name",'password') or die "login failed: $!"; $ftp2->login("name",'password') or die "login failed: $!"; my $gen_server = "server.one.com"; $ftp1->pwd() or die "pwd failed: $!"; unless (-e $uploaded){die "shit $!";} $ftp1->binary() or die "type failed: $!"; my $port1 = $ftp2->pasv(); my $server_port1 = $ftp2->port($port1); my $size1 = $ftp2->size($path); $ftp2->pasv_xfer($path, $gen_server, $short_name); $ftp1->stor($short_name); $ftp1->quit or die "quit failed: $!";
The error message I get from debug is => Can't locate object method "port" via package "server.one.com" at /usr/lib/per l5/site_perl/5.005/Net/FTP.pm line 1057.

Replies are listed 'Best First'.
Re: FTP Transfer
by ChOas (Curate) on Oct 18, 2000 at 17:29 UTC
    Hmmmm...

    What about changing
    $ftp2->pasv_xfer($path, $gen_server, $short_name);
    in:
    $ftp2->pasv_xfer($path, $ftp1, $short_name);

    Seems to work for me....

    I think ;)))
      i gave it a try, but now its giving me an Possible PASV port theft, cannot open data connection error!!
Re: FTP Transfer
by princepawn (Parson) on Oct 18, 2000 at 16:37 UTC
    Is this really the code you ran? In the very first line you bind $ftp_1 but all through the code you use $ftp1

    use strict and use warnings (or -w if perl version < 5.6.0) would have caught this

      sorry, $ftp_1 and $ftp1 are the same (typo!!) i am using strict and -w.