My problem is simple im sure, the thing is that i cant see it :o)

I have a script that takes 5 arguments:
"filelist hostlist username password directory"

It starts a ftp session to the first node in the hostlist and transfers all the files from the filelist.

This works fine as long as i only have one node in the nodelist.. if i have more it just goes:

$ ./ftpbackup.pl filelist.txt hostlist.txt <username> <password> /remote/directory
Connecting to host1.com
Getting file1
Getting file2
Connecting to host2.com

And nothing more one reson can be that i just started learning perl last week.. ;o)

Thanks!
Tommy Rohde - yxol@fetburk.nu

#!/usr/bin/perl -w # # Comments are allowed in both the file and host list if # the comment row begins with a '#' sign. # Entries in the file and host list should be seperated with # a new row. spaces or other signs will make the script fail. # 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 $backupnode = undef; open(FilesToGet, $filelist) or die "can't open filelist $filelist: $!\n"; open(HostsToGet, $hostlist) or die "can't open hostlist $hostlist: $!\n"; HOSTLOOP: while (<HostsToGet>) { next HOSTLOOP if /#/; print STDERR "Connecting to $_" if $debug > 3; chomp; $backupnode = $_; FILELOOP: while (<FilesToGet>) { next FILELOOP if /#/; my $ftp = Net::FTP->new($backupnode); $ftp->login($username, $password); $ftp->cwd($home); print STDERR "Getting $_" if $debug > 3; chomp; $ftp->get($_,"$backupnode." . $_); $ftp->quit; } }

Edit kudra, 2001-11-07 Changed title


In reply to Problems with Net::FTP by enaco

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.