Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-02-2009, 10:20 PM   #1
Registered: Apr 2004
Posts: 682

Rep: Reputation: Disabled
Perl - Net::FTP - download all PDF files

I'm using Perl's Net::FTP to download some files. At the moment it is downloading only one file. I want to download all PDF files. Can someone please show me how do I do that? Thanks.

Here's my code:

#!/usr/bin/env perl

use strict;
use warnings;
use sigtrap;
use diagnostics;

use Net::FTP;

my $host="";
my $directory="report/marketing/outgoing/day";
my $username = "user";
my $password = "password";
my $filename = "file_1.pdf";

my $ftp = Net::FTP->new($host, Debug => 0)
or die "Cannot connect to marketing: $@";

      or die "Cannot login ", $ftp->message;

      or die "Cannot change working directory ", $ftp->message;

      or die "get failed ", $ftp->message;

Old 07-03-2009, 12:39 AM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Well ... guess you'll want to retrieve a directory listing,
filter out the PDFs and retrieve them in a loop?

Old 07-03-2009, 02:35 AM   #3
Registered: Sep 2007
Location: Berlin
Distribution: Slackware
Posts: 509

Rep: Reputation: 41
That seems what you have to do - see this thread for suggestions:

Or, you just try wget with -Apdf
Old 07-03-2009, 06:43 AM   #4
Senior Member
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,548

Rep: Reputation: 136Reputation: 136

i guess that will work
Old 07-03-2009, 11:25 AM   #5
Registered: Jul 2005
Location: maryland
Distribution: Ubuntu 9.04
Posts: 88

Rep: Reputation: 17
i agree with tinkster, i did something like that before, what you want to do is get a list of the files you want and then select only the pdf files, after that just use a for loop



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl Net::FTP problem LidoShuffle Programming 2 06-02-2009 05:54 PM
Perl script to download the files from FTP server peddip Linux - Server 4 03-23-2009 09:49 AM
perl files download instead of parsed on apache2 mod-perl2 not parsing perl files zeigerpuppy Debian 1 02-16-2006 05:31 AM
Urgent Help: Perl FTP Script Using NET::FTP xboxter Programming 8 05-16-2005 06:57 PM
perl and Net::FTP question Tomasfuego Programming 0 12-17-2003 08:13 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:37 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration