Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

multiftp.pl

by ergowolf (Monk)
on May 05, 2000 at 16:24 UTC ( #10350=sourcecode: print w/replies, xml ) Need Help??
Category: FTP
Author/Contact Info ergowolf
Description: This script gets multiple files from multiple file servers. It requires some minor tweaks to change the script. For example, you could change get to put or the user name from Randal to vroom. It will take aas many servers and files as you would like.
use Net::FTP; 

my $ftp;
my $filename;
my @files = ('file1','file2');
my %servers = (
        'box1' => 'password',
        'box2' => 'password',
        );

chdir "path/where/you/want/the/files";

foreach (keys %servers) {
# line 16
    $ftp = Net::FTP -> new($_);
    print $ftp -> message(), "\n";
    $ftp -> login('Randal', $servers{$_});
    print $ftp -> message(), "\n";
    $ftp -> binary();
    print $ftp -> message(), "\n";
    $ftp -> cwd('/your/path');
    print $ftp -> message(), "\n";
    
    foreach $filename (@files) {
        $ftp -> get( "$filename", "$_$filename");
        print $ftp -> message(), "\n";
    }
print "Completed $_\n\n";
$ftp -> quit();
}

exit;
Replies are listed 'Best First'.
RE: multiftp.pl
by Anonymous Monk on Jun 09, 2000 at 00:36 UTC
    One of the shortcomings of the Net:FTP module is the lack of the 'multi' commands (mget, mput) A quick addition to code can populate the @files array even given a mask. @files = $ftp -> ls("*.tar.gz"); Gets all of the archives from the server.
Re: multiftp.pl
by cybear (Monk) on May 24, 2002 at 18:54 UTC
    ergowolf, What is it that you are doing with the message() statements?
    Are you assigning somthing to it, or calling something from it?

    On another note...
    I have a script that FTP's a file to a VAN (Value-added Network).
    Once the file transfer is complete an ILOG number is returned
    from the VAN. This number 99.99999999% certifies that the file
    was received correctly.

    Currently, in order to capture that number, I need to turn
    the debug on Net::FTP to 1 and redirect STDERR to a file.
     my $ftpSession = Net::FTP-> new("$host", Debug => 1); open (STDERR, ">>/detaillogfile.log");

    Can you think of a better way?

      $ftp->message() is mentioned in the documentation - it returns the last line that was received from the server, so it would fit your purpose very nicely, read up the Net::FTP POD :)
        $ftp->message() grabs the last line STDOUT, but not the previous lines, nor STDERR... I'm trying to do the same thing...debug a troublesome FTP connection, and I'd like everything Debug -> 1 can give me. any way to redirect STDOUT and STDERR to a hash? (or a pair of them?)
Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://10350]
help
Chatterbox?
[ambrus]: choroba: that doesn't matter, the cookies are independent on the webserver, they just have to contain your username and crypted password with a seed of the user's choice, you can change the hostname or even construct a cookie without asking the server
[ambrus]: choroba: and for perlmonks (but not for everything2), you don't even need a cookie, you can just send a username and password parameter in every request, and this is even documented in What XML generators are currently available on PerlMonks?
[holli]: i admire you choroba, if i had to work at such a place, i wouldn't last long. as bosses don't like if someone calls them clueless idiots
[ambrus]: (The cookie format is not documented anywhere afaik, but it's trivial to reverse engineer even without being a pmdev.)
[holli]: or "ignorant bricks" (that is not a typo)

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2017-10-24 11:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (289 votes). Check out past polls.

    Notices?