Monday, April 4, 2011

want a shell command to Download a Package, but it has a Redirecting Link... CURL it down

One of the things happened to me several time is when I'm writing an automated script for set of utilities to get downloaded from Internet (then installed and configured) on the Linux Box, so that I don't have to go through monotonous set of boring algorithm to set-up an environment again and again.

But, one or more links in that set of packages required ain't available via Package Manager's generosity... so it's required to script it's download from any repository or remote download locations.
If it's a direct download link... the most used utility is 'wget'.

In that process several times I get stuck with download links like that we get at (superb open-source content) website similar to, where even if you copy the final redirected link and paste it in your script that wouldn't work after some moments.

So, you require a shell-command/utility which can be used very easily to download the resource after following the redirected link at the time of execution... and the savior is our same old CURL.


How-To Use It

+ To download a resource on your storage using 'curl'
   |=+ Command: # curl -o file_name Link_Of_Resource
   |=+ Example:
#curl -o GaneshaAarti.rar

+ To download a resource from a redirecting link using 'curl', it gets a new switch '-L' for job
  |=+ Command: #curl -L -o file_name Link_Of_Resource
  |=+ Example:  
#curl -L -o

If you know the required Resource has an online svn/git/hg/bzr/* repository... and you make sure your environment has the respective repository client, then you can even go for cloning the repository instead of downloading from redirecting link... as it might need a little tweaking with change in Resource availability in website (links).