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 > http download via terminal

http download via terminal
Thread Tools
Junior Member
Join Date: Jun 2002
Location: Belgium
Status: Offline
Reply With Quote
Aug 10, 2003, 03:04 AM
 
Hi,

Is is possible to download files thru the terminal that are only available thru http?
Like http://www.site.com/filenametoget.zip or some other file?

Thanks!
     
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
Aug 10, 2003, 03:10 AM
 
If you're running Mac OS X 10.2 (Jaguar) or later, use curl. Download the file using a command like this:

curl -O "http://www.example.com/example.zip"

That's a capital oh, not a number. Put the URL inside quotes in case it contains characters that will be interpreted by the shell (characters like ? or * will be interpreted by the shell).

If you're running Mac OS X 10.1 (Puma) or earlier, you'll want to use wget instead.

wget "http://www.example.com/example.zip"

If you need to use a proxy, prefix the command with something like:

env http_proxy http://proxy.example.com:8080/

- proton
     
Sheep  (op)
Junior Member
Join Date: Jun 2002
Location: Belgium
Status: Offline
Reply With Quote
Aug 10, 2003, 05:36 AM
 
Curl is the best!!
Thank you so much.

I wonder why anybody still needs all those fancy download managers, cURL is IT!
     
Dedicated MacNNer
Join Date: Jul 2001
Location: NC
Status: Offline
Reply With Quote
Aug 10, 2003, 10:37 AM
 
Originally posted by Sheep:
Curl is the best!!
   I'm sure you mean that curl is great. curl and wget are both great and which is better depends on usage. For my purposes, wget is usually better. If you want to download multiple files, wget is usually better. For instance, if you want to download a web page plus all of the images and other files used on the page, then wget is better. If you want to download entire directories then wget is easily preferable because it will even rewrite the links on the page so that the site can be browsed locally. If you're running Jaguar then wget doesn't come with it but Fink will install it.
Gary
A computer scientist is someone who, when told to "Go to Hell", sees the
"go to", rather than the destination, as harmful.
     
Professional Poster
Join Date: Jan 2000
Location: south
Status: Offline
Reply With Quote
Aug 10, 2003, 11:21 AM
 
Hi I am trying to download a linux iso but the curl command doesn't seem to work. THis is what is says:

userX% curl -O http://adelie.polymtl.ca/releases/pp...rp-1.4-cd1.iso
curl: Command not found.

what am I doing wrong here? I even put the url in quotes:

userX% curl -O "http://adelie.polymtl.ca/releases/ppc/1.4/livecd/livecd-g3-grp-1.4-cd1.iso"
curl: Command not found.

I am running 10.2.6
     
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
Aug 10, 2003, 11:50 AM
 
If you didn't install the BSD Subsystem when you installed Mac OS X (10.2 or later), curl will not be installed. You can install it by installing the BSD.pkg file off your Mac OS X 10.2 install disks. I believe it's in the "Additional Packages" or something similar folder on disk 1, but I don't have them handy to check.

After doing that you should probably apply the 10.2.6 Combo updater to update any files in the BSD subsystem that have been patched since the release, but won't have been on your machine because you didn't have them installed.

- proton
     
Professional Poster
Join Date: Jan 2000
Location: south
Status: Offline
Reply With Quote
Aug 10, 2003, 12:12 PM
 
Thanks I don't think I installed that, I will give it a shot.
     
Dedicated MacNNer
Join Date: Dec 2002
Location: someplace
Status: Offline
Reply With Quote
Aug 10, 2003, 12:36 PM
 
Here's a handy alias for your ~/.*chshrc:
cd /downloads/ && curl -O "`pbpaste`" && cd -
     
Dedicated MacNNer
Join Date: Jul 2001
Location: NC
Status: Offline
Reply With Quote
Aug 10, 2003, 01:36 PM
 
Originally posted by gatorparrots:
Here's a handy alias for your ~/.*chshrc:
cd /downloads/ && curl -O "`pbpaste`" && cd -
   I do like that! Even nicer would be to put it in a "do shell script" AppleScript statement in a script that captured the selection from the frontmost app and which was invoked from a contextual menu. That way you could highlight a link and then download it immediately!
   Unfortunately, my current contextual menu managing program doesn't like AppleScripts. Does anyone out there know of one that does?
Gary
A computer scientist is someone who, when told to "Go to Hell", sees the
"go to", rather than the destination, as harmful.
     
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status: Offline
Reply With Quote
Aug 10, 2003, 01:55 PM
 
Originally posted by Gary Kerbaugh:
   I do like that! Even nicer would be to put it in a "do shell script" AppleScript statement in a script that captured the selection from the frontmost app and which was invoked from a contextual menu. That way you could highlight a link and then download it immediately!
   Unfortunately, my current contextual menu managing program doesn't like AppleScripts. Does anyone out there know of one that does?
Doesn't your contextual menu have a thing for that already? In Mozilla I can right click on any link and get the option "Save Link Target As..." and a slew of others.
-DU-...etc...
     
Sheep  (op)
Junior Member
Join Date: Jun 2002
Location: Belgium
Status: Offline
Reply With Quote
Aug 10, 2003, 03:13 PM
 
Well, my goal was to download a couple of hunderd file all of the following structure 0001.gif thru 0446.gif. I thought curl could just get one file and then you had to retype with 0002 etc. Wanted to make a shell script that loops that, but curl has this nifty option that it can get a alphanumeric series of its own just by putting the first (0001) and last (0446) filename between [].
So you get something like this: www.domain.com/[0001-0446].gif
And thats very cool!
     
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status: Offline
Reply With Quote
Aug 11, 2003, 05:57 AM
 
Originally posted by Gary Kerbaugh:
If you're running Jaguar then wget doesn't come with it but Fink will install it.
i do wish people wouldn't harp on about Fink all the time, when it isn't needed for a lot of things. all you have to do, is look properly:

http://www.apple.com/downloads/macos...urce/wget.html
"Have sharp knives. Be creative. Cook to music" ~ maxelson
     
Dedicated MacNNer
Join Date: Jul 2001
Location: NC
Status: Offline
Reply With Quote
Aug 11, 2003, 08:02 AM
 
Originally posted by philzilla:
i do wish people wouldn't harp on about Fink all the time, when it isn't needed for a lot of things. all you have to do, is look properly:

http://www.apple.com/downloads/macos...urce/wget.html
   Properly???? Wow! I was wondering who decided that! Since, we now know, I have a few bones to pick with you. Could you get that link that link to work "properly" and keep my version always updated to the latest automatically? While you're at it, there are several thousand UNIX ports that don't seem to have proper listings there; could you fix that? Last but not least, there's a president I'd like to talk to you about ...
Gary
A computer scientist is someone who, when told to "Go to Hell", sees the
"go to", rather than the destination, as harmful.
     
Dedicated MacNNer
Join Date: Jul 2001
Location: NC
Status: Offline
Reply With Quote
Aug 11, 2003, 08:51 AM
 
Originally posted by utidjian:
Doesn't your contextual menu have a thing for that already? In Mozilla I can right click on any link and get the option "Save Link Target As..." and a slew of others.
   In a browser, yes, of course. I misspoke, sorry. I meant to say highlight a URL instead of link. I was thinking of something that worked in any application. BigCat Scripts don't work consistently. I'm now trying "On My Command" which seems to work better but it's rather difficult to customize. I thought someone might have other suggestions.
Gary
A computer scientist is someone who, when told to "Go to Hell", sees the
"go to", rather than the destination, as harmful.
     
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status: Offline
Reply With Quote
Aug 11, 2003, 09:37 AM
 
Originally posted by Gary Kerbaugh:
Last but not least, there's a president I'd like to talk to you about ...
sorry, that would be a matter for the political lounge, and i don't go in there.
"Have sharp knives. Be creative. Cook to music" ~ maxelson
     
msh
Junior Member
Join Date: Mar 2002
Location: NY
Status: Offline
Reply With Quote
Aug 26, 2003, 12:00 PM
 
Originally posted by Sheep:
Well, my goal was to download a couple of hunderd file all of the following structure 0001.gif thru 0446.gif. I thought curl could just get one file and then you had to retype with 0002 etc. Wanted to make a shell script that loops that, but curl has this nifty option that it can get a alphanumeric series of its own just by putting the first (0001) and last (0446) filename between [].
So you get something like this: www.domain.com/[0001-0446].gif
And thats very cool!
I've read the man page and discovered that feature, but curl doesn't work for me when I do that.

Can I use the [] in the middle of a file. For example for file2000-10-04t[01-10].zip ?

I've tried that and other permutations and all I get is a curl: no match error. I can only specify each file one at a time. What am I missing? This is with 10.2.6 and the man page says curl is 7.7.2
     
Senior User
Join Date: Nov 2001
Location: State of Denial
Status: Offline
Reply With Quote
Aug 26, 2003, 01:53 PM
 
Originally posted by msh:
I've read the man page and discovered that feature, but curl doesn't work for me when I do that.

Can I use the [] in the middle of a file. For example for file2000-10-04t[01-10].zip ?

I've tried that and other permutations and all I get is a curl: no match error. I can only specify each file one at a time. What am I missing? This is with 10.2.6 and the man page says curl is 7.7.2
Yes; you need to wrap your URL in quotes.

e.g.,

curl -O 'http://somedomain.com/file2000-10-04t[01-10].zip'
[Wevah setPostCount:[Wevah postCount] + 1];
     
Fresh-Faced Recruit
Join Date: Sep 2003
Status: Offline
Reply With Quote
Sep 1, 2003, 04:51 PM
 
Can you get multible files in one url in wget aswell ? Couldn't get curl to work with user and passwords :-(
     
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status: Offline
Reply With Quote
Sep 1, 2003, 06:17 PM
 
Originally posted by pisosse:
Can you get multible files in one url in wget aswell ? Couldn't get curl to work with user and passwords :-(
run man wget and check that out

or wget -r http://username:password@www.somesite.com/ will grab everything for you
"Have sharp knives. Be creative. Cook to music" ~ maxelson
     
Fresh-Faced Recruit
Join Date: Sep 2003
Status: Offline
Reply With Quote
Sep 2, 2003, 05:10 AM
 
what I'll like to do is to get a series of .mov files in a player connected to a link of many links in a site. I think that I'll get all the players from that site if I use -r command in wget.

But in the player each movie have a url. like :

the first
http://mental@www.mentalusd.k12.ca.u...es/01/0101.mov

the last
http://mental@www.mentalusd.k12.ca.u...es/19/1903.mov

In this post its told that curl have this bracket command that get the whole series in one go like:

http://mental@www.mentalusd.k12.ca.us/training/movies/[01-19]/[0101-1903].mov

but I can't get curl to connect with password wich I can with wget, but I can't get wget to down the series.

there you have it:-)
     
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
Sep 2, 2003, 05:30 AM
 
curl supports user authentication. Just get the file something like this:

curl -u username:password "http://www.example.com/file.tgz"

- proton

[Edit: kill smilies]
     
Fresh-Faced Recruit
Join Date: Sep 2003
Status: Offline
Reply With Quote
Sep 2, 2003, 05:48 AM
 
tried that a couple of times but couldn't get it to work.. I should try when sober and fresh maybe??

dunno
     
Fresh-Faced Recruit
Join Date: Sep 2003
Status: Offline
Reply With Quote
Sep 2, 2003, 07:49 AM
 
this is what i get...

curl -u orange:orange "http://orange@http://www.orangeusd.k12.ca.us/train...es/19/1906.mov"
curl: (6) Couldn't resolve host 'orange@www.orangeusd.k12.ca.us'
     
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Sep 2, 2003, 08:43 AM
 
Originally posted by pisosse:
this is what i get...

curl -u orange:orange "http://orange@http://www.orangeusd.k12.ca.us/train...es/19/1906.mov"
curl: (6) Couldn't resolve host 'orange@www.orangeusd.k12.ca.us'

Try this:

Code:
curl -u orange:orange "http://www.orangeusd.k12.ca.us/training/vtcmovies/flashmxdesign/movies/19/1906.mov
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
Fresh-Faced Recruit
Join Date: Sep 2003
Status: Offline
Reply With Quote
Sep 2, 2003, 10:39 AM
 
something right happend but it seems like it downloads stright to terminal coz i get something like 23 million lines of this

     
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Sep 2, 2003, 10:46 AM
 
Originally posted by pisosse:
something right happend but it seems like it downloads stright to terminal coz i get something like 23 million lines of this

Well, you have to specify output, or you get the file to standard out (in this case, your terminal).

To put it in a specified file (myfile.mov), do this:

Code:
curl -o myfile.mov -u orange:orange "http://www.orangeusd.k12.ca.us/training/vtcmovies/flashmxdesign/movies/19/1906.mov
If you want to accept the default output name (which is the filename, in this case 1906.mov), do this:

Code:
curl -O -u orange:orange "http://www.orangeusd.k12.ca.us/training/vtcmovies/flashmxdesign/movies/19/1906.mov
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
Fresh-Faced Recruit
Join Date: Sep 2003
Status: Offline
Reply With Quote
Sep 2, 2003, 01:39 PM
 
ALAS SUCCES AT LAST!!!!!!!

thanks everybody (especially you arkham_c!)

This unix thing is marvolus!!

and this forum made me an happy camper

     
Fresh-Faced Recruit
Join Date: Sep 2003
Status: Offline
Reply With Quote
Sep 2, 2003, 03:03 PM
 
Ok I'm still happy but just one quistion...

when I tell curl to download from chapter one tru nineteen

like this

*****/[01-19]/[0101-1906]/***

but theres only 4 files in chapter 01 and 5 files in chapter 01 and so one

so curl gets the 4 files in chapter 1 and then try and download from 0105 and probably all the way to 9999 before it goes to chapter 02.

Is there anyway around downloading chapter by chapter???

thanks again folks
     
   
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 08:14 AM.
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