Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I costumized the script to fit my needs, i hope you like it, it uses arrays and it also takes a hostlist as a argument

I only coded perl for 1,5 week now, thats why its kind of ugly :o)

#!/usr/bin/perl # # Entries in the file and host list should be seperated with # a new row. spaces or other signs will make the script fail. # You can use comments if you put a '#' sign in front of the # line, but it will make the printout of number of hosts and # files that are beeing backuped to show the wrong numbers. # use Net::FTP; use strict; my $usage = "$0 filelist hostlist username password directory\n"; my $filelist = $ARGV[0] or die "$usage"; my $hostlist = $ARGV[1] or die "$usage"; my $username = $ARGV[2] or die "$usage"; my $password = $ARGV[3] or die "$usage"; my $home = $ARGV[4] or die "$usage"; my $debug = 5; my @hostarr; my @filearr; my $nr = 0; open(FilesToGet, $filelist) or die "can't open filelist $filelist: $!\n"; open(HostsToGet, $hostlist) or die "can't open hostlist $hostlist: $!\n"; @hostarr = <HostsToGet>; chomp @hostarr; my $hostarrnr = @hostarr; @filearr = <FilesToGet>; chomp @filearr; my $filearrnr = @filearr; print "\nHosts: $hostarrnr\n"; print "Files: " . ($filearrnr * $hostarrnr) . "\n"; print "\n"; for (my $nr1 = 0; $nr1 < $hostarrnr; $nr1++) { next if ($hostarr[$nr1] =~ /^#/ | undef); print STDERR "Connecting to $hostarr[$nr1]\n" if $debug > 3; my $ftp = Net::FTP->new($hostarr[$nr1]); $ftp->login($username, $password); $ftp->cwd($home); for (my $nr2 = 0; $nr2 < $filearrnr; $nr2++) { next if ($filearr[$nr2] =~ /^#/ | undef); print STDERR "Getting $filearr[$nr2]\n" if $debug > 3; $ftp->get($filearr[$nr2],("$hostarr[$nr1]." . $filearr[$nr2])) +; } $ftp->quit; }

In reply to Re: ftplist.pl by enaco
in thread ftplist.pl by jjdeterick

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 19:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found