Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

FTP Question

by LostS (Friar)
on Dec 17, 2002 at 14:44 UTC ( [id://220529]=perlquestion: print w/replies, xml ) Need Help??

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

OK Today's job is to take this CD that has over 40,000 badge images on it. They are all in 1 directory. When I try using just an FTP program it doesn't upload everything and is ticking me off. So What I was wondering to do is create a script. It will get all the file names and dump them to an array. Then for each entry in the array it would FTP it to the server to the specific location. Heck I might go ahead and make it do the file sorting and making sure the file names are set correctly... But anyways... Can someone point me in the direction of an article to do FTP or a module??

-----------------------
Billy S.
Slinar Hardtail - Hand of Dane
Datal Ephialtes - Guildless
RallosZek.Net Admin/WebMaster

perl -e '$cat = "cat"; if ($cat =~ /\143\x61\x74/) { print "Its a cat! +\n"; } else { print "Thats a dog\n"; } print "\n";'

Replies are listed 'Best First'.
Re: FTP Module Suggestions
by cjf-II (Monk) on Dec 17, 2002 at 14:47 UTC

      In addition, you may also wish to look at the samples in the FTP Stuff section of the Code Catacombs.

      You did not say why a standard FTP program was failing. Is it timing out? Failing because of the size of the directory? Or was it failing because you need something with a little more power to do things like lowercase or uppercase all filenames, remove spaces, and/or split the files into directories by one or more initial letters or something?

      Hopefully the excellent references suggested thus far by respondents to your post will be of help. Failing that, posting additional information may allow someone to offer you additional ideas or snippets that may be useful. In either case, I hope you find what you seek, and, perhaps, will even take time to post the solution you find, to aid those who may come after with similar needs.

      Update: You may also wish to check the Snippets Section for postings. grinder has an interface which may make that easier to do for what you seek.

      Update: Found a basic snippet of code I had that might help you get started.

      # # Assumes %filelist and %connectinfo defined and # filled earlier # my $ftp = Net::FTP->new($connectinfo{'host'}; $ftp->login($connectinfo{'user'}, $connectinfo{'pass'}); my $current_target_directory = ""; foreach my $filename (sort(keys(%filelist))) { if ($current_target_directory ne $filelist{$filename}{'target'}) { $current_target_directory = $filelist{$filename}{'target'}; $ftp->cwd($current_target_directory); } $ftp->put($filename); print($filename, "\n"); } $ftp->quit;

      Update: Modified title.

        OK for why it is failing... It isn't failing... It is just not uploading allt he stupid images. What it is is a CD with a directory called Images. In this directory is approx 42,000 badge images. No I go to command prompt ftp to the server and say mput e:\images\*.jpg and it begins uploading and finishes without complaining. But when I run my script to check to see if the user has an image I notice some images are not uploaded. Like they are left out and ignored. I have tried using the command line from Windows 2000 and tried using CuteFTP (It wont even start with that program) and tried WS_FTP and same thing. It uploads but doesn't upload everything. I think it is due to the number of files. I don't think one should put over 10,000 files in a single directory. Just me I dunno... That is why I am needing to do this. But thank you all for this help. It has helped get me in the direction I need to go to solve this issue and move on to the next. Thank you all...

        -----------------------
        Billy S.
        Slinar Hardtail - Hand of Dane
        Datal Ephialtes - Guildless
        RallosZek.Net Admin/WebMaster

        perl -e '$cat = "cat"; if ($cat =~ /\143\x61\x74/) { print "Its a cat! +\n"; } else { print "Thats a dog\n"; } print "\n";'
Re: FTP Question
by Mr. Muskrat (Canon) on Dec 17, 2002 at 14:56 UTC
Re: FTP Question
by gjb (Vicar) on Dec 17, 2002 at 14:50 UTC

    If you search CPAN for FTP, you'll find Net::FTP which sounds kind of promising.

    Hope this helps, -gjb-

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (None)
    As of 2024-04-25 01:33 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found