0

Using a ubuntu 16.04 what I do is :

  1. Download the .sh script using wget https://gist.githubusercontent.com/...
  2. Turn the .sh file executable sudo chmod guo+x sysInit.sh
  3. Execute the code through sudo ./sysInit.sh

I was wondering if it is possible to run the code directly from the web. Would be something like: sudo ./ https://gist.githubusercontent.com/....

Is it possible to do that?

IgorAlves
  • 5,086
  • 10
  • 52
  • 83

3 Answers3

2

Yes, it is possible using curl and piping the result to sh.

Try the following command.

curl https://url-to-your-script-file/scriptFile.sh | sh

Vivek
  • 2,665
  • 1
  • 18
  • 20
2

You can use cUrl to download and run your script. I don't think its installed by default on Ubuntu so you'll have to sudo apt-get install curl first if you want to use it. To download and run your script with sudo just run

curl -sL https://gist.githubusercontent.com/blah.sh | sudo sh

Be warned this is very risky and not advised for security reasons. See this related question why-using-curl-sudo-sh-is-not-advised

Dave Carruthers
  • 542
  • 1
  • 8
  • 29
0

No, sudo only works from a command line prompt in a shell

Mike Slinn
  • 7,705
  • 5
  • 51
  • 85