Execute bash script from URL

Solution 1:

source <(curl -s http://mywebsite.com/myscript.txt)

ought to do it. Alternately, leave off the initial redirection on yours, which is redirecting standard input; bash takes a filename to execute just fine without redirection, and <(command) syntax provides a path.

bash <(curl -s http://mywebsite.com/myscript.txt)

It may be clearer if you look at the output of echo <(cat /dev/null)

Solution 2:

This is the way to execute remote script with passing to it some arguments (arg1 arg2):

curl -s http://server/path/script.sh | bash /dev/stdin arg1 arg2

Solution 3:

For bash, Bourne shell and fish:

curl -s http://server/path/script.sh | bash -s arg1 arg2

Flag "-s" makes shell read from stdin.

Solution 4:

Use:

curl -s -L URL_TO_SCRIPT_HERE | bash

For example:

curl -s -L http://bitly/10hA8iC | bash

Solution 5:

Using wget, which is usually part of default system installation:

bash <(wget -qO- http://mywebsite.com/myscript.txt)