Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Using NET::FTP to download Files

by dReKurCe (Scribe)
on Jun 01, 2005 at 02:32 UTC ( [id://462275]=perlquestion: print w/replies, xml ) Need Help??

dReKurCe has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Monks:

I am interested inleading up to a reply to How do I make Net::FTP use wildcards and I have put together this script so far. It is meant to backup a diectory of images to a local file.

The following code produces the following output:
#! /usr/bin/perl #FTP to2600@darkphiber.ca for seCr33n CaPtu7e fetch # #Authored:/home/japh #% whoami #dReKurCe # #Tue May 31 19:17:51 EDT 2005 # # # use Net::FTP; $hostname='darkphiber.ca'; $username='to2600@darkphiber.ca'; $hack_the_planet='h4x0r5'; #update by OM Tue May 31 17:15:45 EDT 2005 $home='/home/neutrin0/2600'; $filename="neutrin0.to2600.3105a.jpg"; # open conection to ftp.darkphiber.ca $ftp=Net::FTP->new($hostname); $ftp->login($username,$hack_the_planet); print "Current Listing of $username"; @dirlisting=$ftp->ls(),"\n"; atomize(@dirlisting); #retrieve $filename and exit #not sure how the output of atomize should be utilized here $ftp->get($filename); $ftp->quit; sub atomize{ for $screencapture(@philes){print "output of ftp listing->$screencaptu +re\n"} }
output of ftp listing->neutrin0.to2600.3105a.png
output of ftp listing->neutrin0.to2600.3105b.png
output of ftp listing->neutrin0.to2600.3105c.png
output of ftp listing->neutrin0.to2600.3105d.png


How can i utilize the output of the method or (err sub routine) in atomize to get the image to my harddrive?


Thanks Monks
dReKurCe

Replies are listed 'Best First'.
Re: Using NET::FTP to download Files
by brian_d_foy (Abbot) on Jun 01, 2005 at 02:54 UTC

    Once you get the names of the files (which you put in @dirlisting), you need to go through each of those file and get() it. You already have the $ftp->get() line in there, although it's not doing anything.

    my @dirlisting=$ftp->ls(); foreach my $file ( @dirlisting ) { $ftp->get( $file ) or warn "..."; }
    --
    brian d foy <brian@stonehenge.com>

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://462275]
Approved by monkfan
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-26 00:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found