Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run bash script curled from the web

Tags:

linux

bash

I wrote a bash script that should be installable from the web. It should take inputs from the user when run. Below is how I did it but it directly terminates the application without prompting the user to input information.

curl www.test.com/script.sh | bash

I read somewhere that stdin is piped to bash that's why it's not prompting anything.

Any help would be great.

Thanks guys

like image 565
momigi Avatar asked Apr 10 '26 00:04

momigi


2 Answers

Use process substitution:

bash <(curl www.test.com/script.sh)
like image 87
Michael Hoffman Avatar answered Apr 11 '26 14:04

Michael Hoffman


You could try:

 bash -c "$(curl -s www.test.com/script.sh)"

From the bash manpage,

  -c string If the -c option is present, then commands are read from string.  
            If there are arguments after the string, they are
            assigned to the positional parameters, starting with $0.
like image 21
Faiz Avatar answered Apr 11 '26 13:04

Faiz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!