Loading
wget question
Jul 28, 2009 By lmcdougall
I will like to get a list of the files in the directory of an ftp site.
can I use wget to do it?
if yes, the how?
any other method that I can easily implement in bash script is welcome also.
Thanks
Trending Topics
| You Need A Budget | Feb 10, 2012 |
| The Linux powered LAN Gaming House | Feb 08, 2012 |
| Creating a vDSO: the Colonel's Other Chicken | Feb 06, 2012 |
| Your CMS Is Not Your Web Site | Feb 01, 2012 |
| Casper, the Friendly (and Persistent) Ghost | Jan 31, 2012 |
| Razor-qt 0.4 - Qt based Desktop Environment | Jan 30, 2012 |
- Fun with ethtool
- Parallel Programming with NVIDIA CUDA
- Readers' Choice Awards 2011
- 100% disappointed with the decision to go all digital.
- Linux-Based X Terminals with XDMCP
- Validate an E-Mail Address with PHP, the Right Way
- You Need A Budget
- The Linux powered LAN Gaming House
- Why Python?
- Python for Android
- Employment Posters
3 hours 34 min ago - Sure the best distro is
4 hours 54 min ago - BeOS was the best
7 hours 38 min ago - I use Wireshark on a daily
12 hours 8 min ago - buena información
17 hours 15 min ago - One important "bucket" that I didn't note (désolé si qqun deja d
18 hours 16 min ago - Gnome3 is such a POS. No one
1 day 3 hours ago - Gnome 3 is the biggest POS
1 day 3 hours ago - I didn't knew this thing by
1 day 9 hours ago - Author's reply
1 day 13 hours ago





You could also do this using
You could also do this using perl's Net::FTP module:
#!/usr/bin/perl use strict; use warnings; use Net::FTP; #Change your.ftp-host.com to your ftp domain my $ftp = Net::FTP->new("your.ftp-host.com", Debug => 0) or die "Can not connect: $@"; #Change UserName and PassWord to your login information $ftp->login("UserName",'PassWord') or die "Can not log in: ", $ftp->message; #If you want to list your root directory you can comment this out #Or change public_html to where you want to get a file list $ftp->cwd("public_html"); my @list = $ftp->ls($ftp->pwd); my $listing = "list.txt"; open(LISTING, ">$listing"); foreach my $line (@list) { print LISTING $line . "\n"; } close(LISTING)Use "ftp"
Use the ftp command. For example, to get the items in /pub/lj/listings from the LJ ftp server:
This will put the names into filelist.txt. Note that the sed command will produce incorrect results if any of the file names contain blanks. In that case you'll have to use a different method of extracting the file names from the raw results file (filelist.tmp).
Mitch Frazier is an Associate Editor for Linux Journal.