Review your favorite Linux distribution.
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, 11:20 PM   #1
Registered: Apr 2004
Location: Baltimore, MD
Posts: 681

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, 01:39 AM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,047
Blog Entries: 11

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

Old 07-03-2009, 03: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, 07:43 AM   #4
Senior Member
Registered: Jan 2002
Location: germany
Distribution: ubuntu
Posts: 1,507

Rep: Reputation: 128Reputation: 128

i guess that will work
Old 07-03-2009, 12:25 PM   #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 06:54 PM
Perl script to download the files from FTP server peddip Linux - Server 4 03-23-2009 10:49 AM
perl files download instead of parsed on apache2 mod-perl2 not parsing perl files zeigerpuppy Debian 1 02-16-2006 06:31 AM
Urgent Help: Perl FTP Script Using NET::FTP xboxter Programming 8 05-16-2005 07:57 PM
perl and Net::FTP question Tomasfuego Programming 0 12-17-2003 09:13 AM

All times are GMT -5. The time now is 06:04 PM.

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