Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
#!/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 in the host and file lists if you put # a '#' sign in the beginning of the line. # 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; our $nr1 = 0; open(FilesToGet, $filelist) or die "can't open filelist $filelist: $!\n"; open(HostsToGet, $hostlist) or die "can't open hostlist $hostlist: $!\n"; my @hostarr = <HostsToGet>; chomp @hostarr; my $hostarrnr = @hostarr; my @filearr = <FilesToGet>; chomp @filearr; my $filearrnr = @filearr; @hostarr = grep !/^#/, @hostarr; @filearr = grep !/^#/, @filearr; my $filearrnr = @filearr; my $hostarrnr = @hostarr; print "\nHosts: $hostarrnr\n"; print "Files: " . ($filearrnr * $hostarrnr) . "\n\n"; sub ftpbackup { if (my $pid = fork) { 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++) { print STDERR "Getting $filearr[$nr2]\n" if $debug > 3; $ftp->get($filearr[$nr2],("$hostarr[$nr1]." . $filearr[$nr +2])); } $ftp->quit; exit; } } for ($nr1 = 0; $nr1 < $hostarrnr; $nr1++) { ftpbackup(); }

In reply to ftpbackup by enaco

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, 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, 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.
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (2)
    As of 2020-10-25 06:32 GMT
    Find Nodes?
      Voting Booth?
      My favourite web site is:

      Results (249 votes). Check out past polls.