35d34 < my $msg = ''; 37d35 < my $fexists = ''; 58,86c56 < if ($size == 5) { < $CPANhost = $ARGV[0]; < $CPANusername = $ARGV[1]; < $CPANpassword = $ARGV[2]; < $CPANpath = $ARGV[3]; < $dotpos = rindex $CPANpath,'.'; < $slashpos = rindex $CPANpath,'/'; < $nohost = substr $CPANpath,1; < $justfile = substr $CPANpath,(1 + $slashpos); < if ($dotpos == -1) { < $size = 4; < print "Entry $nohost is not a single file.\n"; < #$CPANpassword = ''; < } else { < if (-e $justfile) { < $fexists = 'y'; < } < if ($fexists eq 'y') { < print "File $justfile already exists.\n"; < $CPANpath =~ s/$justfile//g; < $size = 4; < #$CPANpassword = ''; < } else { < $CPANpath =~ s/$justfile//g; < } < } < } else { < print "Usage is via ... perl ftp_url.pl [ftphost=ftp.ozemail.com.au] [ftpusername=mkuulma@ozemail.com.au] ftppassword [subpath=/] [download=]\n"; < } --- > print "Usage is via ... perl ftp_url.pl [ftphost=ftp.ozemail.com.au] [ftpusername=mkuulma@ozemail.com.au] ftppassword [subpath=/]\n"; 96,105c66 < $ftp = connection(); < if ($size == 5) { < # Get the file from the ftp server < print "Got $justfile from $CPANhost .\n"; < $ftp->get($justfile) or < warn "Couldn't get '$justfile', skipped: $!"; < # Close the connection to the FTP server. < $ftp->quit or die "Couldn't close the connection cleanly: $!"; < } else { < $ftp->pasv(); # passive mode --- > $ftp = connection(); 107,108c68 < # Retrieve a recursive directory listing < my @ls = $ftp->ls('-l'); --- > $ftp->pasv(); # passive mode 110,124c70,86 < for my $filex (@ls) { < my $file = $filex; < my (@description, $size); < if (-e $file) { < push @description, 'binary' if (-B _); < push @description, 'a socket' if (-S _); < push @description, 'a text file' if (-T _); < push @description, 'a block special file' if (-b _); < push @description, 'a character special file' if (-c _); < push @description, 'a directory' if (-d _); < push @description, 'executable' if (-x _); < push @description, (($size = -s _)) ? "$size bytes" : 'empty'; < push @description, (($daysago = -M _)) ? " modified $daysago days ago" : ''; < print "\n\t$file is ", join(', ',@description),""; < } --- > # Retrieve a recursive directory listing > my @ls = $ftp->ls('-l'); > > for my $filex (@ls) { > my $file = $filex; > my (@description, $size); > if (-e $file) { > push @description, 'binary' if (-B _); > push @description, 'a socket' if (-S _); > push @description, 'a text file' if (-T _); > push @description, 'a block special file' if (-b _); > push @description, 'a character special file' if (-c _); > push @description, 'a directory' if (-d _); > push @description, 'executable' if (-x _); > push @description, (($size = -s _)) ? "$size bytes" : 'empty'; > push @description, (($daysago = -M _)) ? " modified $daysago days ago" : ''; > print "\n\t$file is ", join(', ',@description),""; 126,127d87 < print "\n\t\n"; < print $msg; 128a89 > print "\n\t";