in reply to Problems with Net::FTP
it should be happier. Although you may want to add some code to make it skip files you grabbed... actually, $_ = '#'; at the bottom of the for loop would do that :)#!/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"; my @FilesToGet = <FilesToGet>; close FilesToGet; open(HostsToGet, $hostlist) or die "can't open hostlist $hostlist: $!\n"; while (<HostsToGet>) { next if /#/; print STDERR "Connecting to $_" if $debug > 3; chomp; $backupnode = $_; for(@FilesToGet) { next 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; } }
- Ant
- Some of my
best work - (1 2 3)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: This should work.. i think
by enaco (Novice) on Nov 08, 2001 at 02:07 UTC |