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

Hello people I get a message to a server I'm uploading to with perl that I don't understand. When it's a bigger file I get this response:

$ perl upload5.pl Net::FTP>>> Net::FTP(2.77) Net::FTP>>> Exporter(5.63) Net::FTP>>> Net::Cmd(2.29) Net::FTP>>> IO::Socket::INET(1.31) Net::FTP>>> IO::Socket(1.31) Net::FTP>>> IO::Handle(1.28) Net::FTP=GLOB(0x8ec59a0)<<< 220 FTP Server ready. Net::FTP=GLOB(0x8ec59a0)>>> USER u63263303 Net::FTP=GLOB(0x8ec59a0)<<< 331 Password required for u63263303 Net::FTP=GLOB(0x8ec59a0)>>> PASS .... Net::FTP=GLOB(0x8ec59a0)<<< 230 User u63263303 logged in Net::FTP=GLOB(0x8ec59a0)>>> TYPE I Net::FTP=GLOB(0x8ec59a0)<<< 200 Type set to I Net::FTP=GLOB(0x8ec59a0)>>> CWD /vids/ Net::FTP=GLOB(0x8ec59a0)<<< 250 CWD command successful Net::FTP=GLOB(0x8ec59a0)>>> ALLO 37155952 Net::FTP=GLOB(0x8ec59a0)<<< 200 ALLO command successful Net::FTP=GLOB(0x8ec59a0)>>> PASV Net::FTP=GLOB(0x8ec59a0)<<< 227 Entering Passive Mode (50,21,179,12,19 +6,219). Net::FTP=GLOB(0x8ec59a0)>>> STOR hydrogenalternativefromfossils.avi Net::FTP=GLOB(0x8ec59a0)<<< 150 Opening BINARY mode data connection fo +r hydrogenalternativefromfossils.avi Net::FTP=GLOB(0x8ec59a0): Timeout at /usr/share/perl/5.10/Net/FTP/data +conn.pm line 74 Use of uninitialized value $@ in concatenation (.) or string at upload +5.pl line 12. put failed $

But the put didn't fail. I haven't tested on this one, but I've found that these binaries are there faithfully, so why the message?

$ cat upload5.pl #!/usr/bin/perl -w use strict; use Net::FTP; my $domain = 'www.altgreendesigns.com'; my $username = ''; my $password = ''; my $file1 = 'hydrogenalternativefromfossils.avi'; my $ftp = Net::FTP->new($domain, Debug=>1, Passive=>1) or die "Can' +t connect: $@\n"; $ftp->login($username, $password) or die "Couldn't login\n"; $ftp->binary(); $ftp->cwd('/vids/') or die "cwd failed $@\n"; $ftp->put($file1) or die "put failed $@\n"; my @list = $ftp->dir(); # print "@list \n"; $

as long as I've got your attention, what's a more "perly" way to write the commented-out print statement: # print "@list \n";the newline doesn't seem to be delimiting the output. Thanks

Replies are listed 'Best First'.
Re: interpreting a server's response
by ikegami (Patriarch) on Jan 13, 2012 at 07:03 UTC
    Except for errors that occur during object construction, the error message is placed in $ftp->message, not $@.

      Can you elaborate? Why is this diagnostic being issued?

        Because if the constructor fails, there's no object on which to call the message method.
Re: interpreting a server's response
by RichardK (Parson) on Jan 13, 2012 at 13:54 UTC

    You could print your list using join

    print join( ',', @list),"\n";

    Or use Data::Dumper

      Net::FTP=GLOB(0x86b28d0)<<< 226 Transfer complete drwx---r-t 6 u63263303 ftpusers 4096 Jan 13 22:04 .,drwx---r-t 6 u63263303 ftpusers 4096 Jan 13 22:04 ..,-rw-r--r-- 1 u63263303 ftpusers 688 Nov 8 20:37 agd1.html,-rw-r--r-- 1 u63263303 ftpusers 341 Jan 10 04:20 index.html,drwxr-xr-x 3 u63263303 root 4096 Jan 13 01:40 logs,-rw-r--r-- 1 u63263303 ftpusers 343 Jan 10 03:26 page1.html,-rw-r--r-- 1 u63263303 ftpusers 251 Jan 11 22:43 page2.html,-rw-r--r-- 1 u63263303 ftpusers 444 Jan 12 00:04 page3.html,-rw-r--r-- 1 u63263303 ftpusers 253 Jan 12 16:43 page4.html,-rw-r--r-- 1 u63263303 ftpusers 277 Jan 13 23:18 page5.html,drwxr-xr-x 2 u63263303 ftpusers 146 Jan 12 23:43 vids,drwxr-xr-x 5 u63263303 ftpusers 4096 Nov 12 19:22 wsb6326330301,drwxr-xr-x 2 u63263303 ftpusers 61 Jun 9 2011 zen

      $ cat upload4.pl #!/usr/bin/perl -w use strict; use Net::FTP; my $domain = 'www.altgreendsigns.com'; my $username = ''; my $password = ''; my $file1 = 'page5.html'; my $ftp = Net::FTP->new($domain, Debug=>1, Passive=>1) or die "Can' +t connect: $@\n"; $ftp->login($username, $password) or die "Couldn't login\n"; $ftp->put($file1) or die "put failed $@\n"; my @list = $ftp->dir(); print join( ',', @list),"\n"; $

      I'm the first to admit that I'll miss things, but I don't see how either Data::Dumper, with considerable wasted effort, applies. Furthermore I don't see how you might think this ouytput better.