How can I run a script locally from a remote server such as www.mysite.com/script.sh
and it does not work.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
If you wrote the script -- meaning that you're absolutely certain you know what it does -- you can just do this:
curl -s http://www.mysite.com/script.sh | sh
curl to fetch the script and pipe it to the Bourne shell. But in general, for anything you didn't actually write yourself, you should do what Grant suggested and read it first, because this is a great way to accidentally run malicious code.
So while this does, of course, "download" the script, it simply sends the data through the pipe rather than saving it to a file.
Then read the script to ensure it doesn't do anything malicious.
chmod +x script.sh and