This post is about running install scripts saved in Gists on Github locally from a Mac Terminal using curl. However, this should work for just about any script saved online and is not in any way limited to gists.
You need to have Command Line Tools for Xcode installed.
First things first, find a script that you want to install. Here is a bash script that i wrote for installing WordPress.
Get the raw version of it and copy the link. Now we are going to curl
that link to get the content in the file and then pass that content to bash
.
1curl -L https://gist.githubusercontent.com/aamnah/aa48749844fffbd42633/raw/install-wp.sh | bash
The -L
flag is for location. If the server reports that the requested page has moved to a different location, this option will make curl redo the request on the new place.
The pipe |
links the two commands so that the output of the curl
command becomes the input of the bash
command.
1curl -L http://xrl.us/installperlosx | bash
The above command will use an install script for Perl off the internet and run it on your Mac.
1curl -sL http://script/location | bash /dev/stdin arg1 arg2
Bourne shell also supports -s
to read from stdin.
1curl -sL http://script/location | bash -s arg1 arg2
For example, the following command runs the script to create a virtual host file while also passing it the argument ‘mydomain.com’ which is needed for the creation of .conf file and /var/www/ directory.
1curl -L https://gist.githubusercontent.com/aamnah/265f2433659b762b480c/raw/aacb8938f27e789812570bf2467816133c2bb9e2/vhost.sh | bash /dev/stdin mydomain.com