Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 10 VPS machines and all of them have to run this one script that I need to change often, but I don't want to change it at 10 places, every time I need to make a change.

I put the script as a plain text file on a remote HTTP server. If I could wget this file and run the contents, that would be great.

But I'm not sure how to do it, or if there are alternative ways to achieve my goal?

share|improve this question
I had a similar situation that i have resolved by a more low-tech approach of using Dropbox and adding the execution to anacron. But if you have access to HTTP server then jordanm's approach will be the easiest for you. – v010dya Jan 4 '14 at 20:27
up vote 7 down vote accepted

As long as you understand the dangers, you can pipe the output to a shell:

wget -O - http://foo.com/somescript | sh
share|improve this answer
Can I put some variables in the remote file? basically: remote file has ./runxxx -id=$id and my local file has id=1 and then wget the remote file – KoKo Jan 4 '14 at 19:02
@KoKo easiest thing to do would be to use an environment variable. – jordanm Jan 4 '14 at 19:21

You can do this in a push or pull way.

If you want to do it the pull way you can use wget or curl. From each host do:

wget -O- http://foo.com/somescript | bash


bash <(wget -O- http://foo.com/somescript)

However it might be easier to do it the push way. From a central host do:

for host in host1 host2 host3; do
  cat script.sh | ssh "$host" bash

Another option would be using puppet or chef. But depending on what you are doing that might be a bit overkill.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.