Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 2734  / 1 Year ago, mon, january 30, 2023, 6:35:05

I wrote a bash script for my use and it works. I want that script to be put in some server in my network and call that script in laptops / desktops in my network itself to execute. Any way I have made a way for that also as below.



Steps:




  1. Install Apache web server in local server.

  2. Put the script in web server.

  3. Make the script executable chmod a+x.

  4. Open terminal in the client machine and install the package curl

  5. Now from the client terminal itself execute the command as:



    sudo curl -kL http://serverip/script.sh | bash



It works fine but only problem is, in my script I have used User input commands like "read variable", that doesn’t work in this scenario. So how to do that is my problem.
Is there any way for me ?


More From » bash

 Answers
7

You can use:



bash -c "$(curl -kL http://serverip/script.sh)"


This will run the script on the local machine. See also man bash to understand why I used -c option. Also double quotes are very important in this case.



Also, as @terdon said in his comment, sudo curl is pointless. If If the script needs local sudo permissions, you need to use sudo in front of bash command.


[#26272] Tuesday, January 31, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
arsleyeuth

Total Points: 72
Total Questions: 121
Total Answers: 112

Location: North Korea
Member since Mon, Oct 31, 2022
2 Years ago
;