enaco has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: This should work.. i think
by claree0 (Hermit) on Nov 07, 2001 at 14:37 UTC | |
|
Re: This should work.. i think
by suaveant (Parson) on Nov 07, 2001 at 19:26 UTC | |
by enaco (Novice) on Nov 08, 2001 at 02:07 UTC | |
|
Re: This should work.. i think
by impossiblerobot (Deacon) on Nov 07, 2001 at 23:47 UTC |