Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Using curl to download a Directory

Using curl to download a Directory
Thread Tools
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Jan 26, 2003, 11:56 AM
 
I never used curl before but I'm beginning to feel the need for it given that I'm spending a lot of time in the command line.

Say that I want to download all files in a remote directory using http. Say that files live at "http://acme.com/share/"

What is the curl command for doing this. Feel free to throw in regex and to recommend a good tutorial on curl usage.

Thanks!

     
Fresh-Faced Recruit
Join Date: Nov 2001
Location: London,England
Status: Offline
Reply With Quote
Jan 26, 2003, 08:44 PM
 
I would suggest you start with this tutorial http://curl.haxx.se/docs/httpscripting.shtml.

Also if you have not already done so also look at the man page for curl.

Apparently you can't retrieve directories like you think since HTTP itself does not work in
that fashion. You must have some idea about the content in the directory before you can fetch it.

The following examples will work :
http://www.numericals.com/file[1-100].txt
http://www.numericals.com/file[001-100].txt

But this will not
http://www.numericals.com/file*.txt

I think wildcarding will work with FTP URLs since FTP is capable of handling wildcards.

It maybe worth considering using another scripting language to invoke curl, perhaps
perl, python or even sh. Though this really depends on how often you wish to use curl
against the same URL.


fudo
     
Dedicated MacNNer
Join Date: Nov 2000
Status: Offline
Reply With Quote
Jan 26, 2003, 09:25 PM
 
I'm not sure how to do it with curl, but you can build yourself a copy of wget and recursively grab webpages and their links by running:

wget -r http://www.acme.com/share/index.html


I have no idea why Apple removed wget from the base install. It's quite handy.
     
DaGuy  (op)
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Jan 27, 2003, 09:57 AM
 
Great, I will start wget. It offers the simplest approach.

I will explore curl a bit further since the regex capability is attractive and I can see how using it from perl could be a great tool.

Thanks for the info.

     
   
Thread Tools
Forum Links
Forum 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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:14 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2