We can run a bash script using the HTML button in the browser using the shell_exec() or exec() or system() functions. The three functions will return the same value if we use these functions. The differences are: shell_exec() returns the complete output as a string.
To invoke a bash function, simply use the function name. Commands between the curly braces are executed whenever the function is called in the shell script. The function definition must be placed before any calls to the function.
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)
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
For bash, Bourne shell and fish:
curl -s http://server/path/script.sh | bash -s arg1 arg2
Flag "-s" makes shell read from stdin.
Using wget
, which is usually part of default system installation:
bash <(wget -qO- http://mywebsite.com/myscript.txt)
Use:
curl -s -L URL_TO_SCRIPT_HERE | bash
For example:
curl -s -L http://bitly/10hA8iC | bash
Try just:
bash <(curl -s http://mywebsite.com/myscript.txt)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With