How do I remotely fetch files from redirected URLs from a terminal?

15

1

I want to fetch a tarball of this python library from terminal. https://github.com/simplegeo/python-oauth2/downloads

However, I cannot simply call

wget https://github.com/simplegeo/python-oauth2/tarball/master

because doing so retrieves a web page. How do I fetch this resource from terminal?

David Faux

Posted 2012-07-18T03:42:25.850

Reputation: 4 477

web browser from terminal, such as lynx? – Jakob Weisblat – 2012-07-18T03:49:42.597

Answers

20

Use curl instead – and if you know it's a tar archive, you can just pipe the output into tar to extract it automatically.

curl -L https://github.com/simplegeo/python-oauth2/tarball/master | tar xz

If you just want to save the file, use the -o option with your own name, or try -O, which will use the remote file name automatically (but might not always work).

From man curl:

-L: If the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option will make curl redo the request on the new place

slhck

Posted 2012-07-18T03:42:25.850

Reputation: 182 472