Without any code, it's difficult to know what you're trying to do. However, following is a script I wrote to automate the download of all files in a give directory, or simply a given file. It's quick and dirty, and I'm sure could be cleaned considerably, but when I wrote it, I needed it "yesterday".....

#!/usr/bin/perl # # gets $FILE in $DIR from $HOST # # the following command line parameters are accepted: # # -h host IP and port (ex: 192.168.1.1 22) # -u userid (ex: -u anonymous) # -p password (ex: -p your@email.com) # -d directory (ex: -d /pub/data/) # -f file (ex: -f filename.txt) # NOTE: if -f is not passed, then the entire directory is downlo +aded $BadInput = ""; use Getopt::Long; GetOptions("h=s" => \$HOST, "port=s" => \$PORT, "u=s" => \$USERNAME, "p=s" => \$PASSWORD, "d=s" => \$DIR, "f=s" => \$FILE); use File::stat; $fileinfo = stat("$ENV{HOME}.batchftprc"); if (!($HOST)) { print "No host specified\n"; $BadInput = "Y"; } if (!($USERNAME)) { print "No userid specified\n"; $BadInput = "Y"; } if (!($PASSWORD)) { print "No password specified\n"; } if ((!($DIR)) and (!(-s("$ENV{HOME}/.batchftprc")))) { print "No directory specified\n"; $BadInput = "Y"; } if ($BadInput) { print "correct usage is: perl batchftp.pl --h=<HOST> [--port=< +PORT>] --u=<USERID> --p=<PASSWORD> --d=<DIRECTORY> [--f=<FILENAME>]\n +"; print "items enclosed in [] are optional\n"; print "-d is required unless $ENV{HOME}/.batchftprc exists\n"; print "probably want to use & as well\n"; exit; } if ($DIR) { push(@dir, $DIR); } else { open(CONFIG, "$ENV{HOME}/.batchftprc") or die "-d not specifie +d and could not open $ENV{HOME}/.batchftprc: $!"; while (chomp($DIR = <CONFIG>)) { push(@dir, $DIR); } } use Net::FTP; $ftp = Net::FTP->new("$HOST $PORT") or die "can't connect to $HO +ST: $!\n"; $ftp->login($USERNAME, $PASSWORD) or die "can't login: $!\n"; foreach $DIR (@dir) { $ftp->cwd($DIR) or die "can't change to $DIR +: $!\n"; if ($FILE) { $ftp->get($FILE) or die "can't get $FILE: $!\ +n"; } else { @list = $ftp->ls or die "can't get ls: $!\n"; foreach $FILE (@list) { $ftp->get($FILE) or die "in foreach can't get + $FILE: $!\n"; } } } $ftp->quit;

The format of .batchftprc is:

/directory01/whatever /directory02 /directory03/whatever/you/want

Hope this helps.

If things get any worse, I'll have to ask you to stop helping me.


In reply to (shockme) Re: FTP by shockme
in thread Capturing Net::FTP output by WintersMystic

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.