I am running Linux.

I'm writing an installer in Bash for an application I wrote.

The installer needs to be able to download different Bash scripts and run them automatically?

How would I go about this?


Take a look at wget.

It comes pre-installed on most Linux OSs.

It works as simply as typing wget <the-url-to-download>.

In your case, you'll probably want to do something along these lines:

wget https://www.example.com/files/coreinstall.sh -O new-filename.sh
chmod +x new-filename.sh

Be careful not to mistype the URL, because the above script will download and run whatever is at that URL.

Alternatively, use curl.

If wget is not installed and curl is available, use it instead of wget with -o (lower-case) instead of the -O switch:

curl https://www.example.com/files/coreinstall.sh -o new-filename.sh
  • 3
    If you don't need to keep the script lying around: wget $url -O - | sh – glenn jackman Feb 4 '14 at 18:13
  • 1
    That would work, but as he is using bash, he would need to make sure he starts his scripts with #!/bin/bash, or replace the sh on the end to bash, i.e. wget $url -O - | bash. – IBPX Apr 28 '14 at 21:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.