Run bash script from web

wget -q -O - http://www.example.com/automation/remotescript.sh | bash /dev/stdin parameter1 parameter2
Use this command to execute the contents of http://www.example.com/automation/remotescript.sh in the local environment. The parameters are optional. Alterrnatives to wget: CURL: curl -s http://www.example.com/automation/remotescript.sh | bash /dev/stdin param1 param2 W3M: w3m -dump http://www.example.com/automation/remotescript.sh | bash /dev/stdin [param1] [param2] LYNX: lynx -source http://www.example.com/automation/remotescript.sh | bash /dev/stdin [param1] [param2]

0
By: paulera
2015-02-16 16:55:09

These Might Interest You

  • echo "ls" > script.bash; This is my script, a simple 'ls'. gpg -c script.bash; Here I encrypt and passord-protect my script. This creates file script.bash.gpg. cat script.bash.gpg | gpg -d --no-mdc-warning | bash Here I open file script.bash.gpg, decrypt it and execute it.


    -2
    echo "ls" > script.bash; gpg -c script.bash; cat script.bash.gpg | gpg -d --no-mdc-warning | bash
    betsubetsu · 2013-03-10 09:34:12 1
  • (Please see sample output for usage) script.bash is your script, which will be crypted to script.secure script.bash --> script.secure You can execute script.secure only if you know the password. If you die, your script dies with you. If you modify the startup line, be careful with the offset calculation of the crypted block (the XX string). Not difficult to make script editable (an offset-dd piped to a gpg -d piped to a vim - piped to a gpg -c directed to script.new ), but not enough space to do it on a one liner. Show Sample Output


    5
    echo "eval \"\$(dd if=\$0 bs=1 skip=XX 2>/dev/null|gpg -d 2>/dev/null)\"; exit" > script.secure; sed -i s:XX:$(stat -c%s script.secure): script.secure; gpg -c < script.bash >> script.secure; chmod +x script.secure
    rodolfoap · 2013-03-09 11:16:48 5
  • Writes out the shebang line (#!/bin/bash) to the script.


    -4
    echo '#!'$(which bash) > script.sh
    sharfah · 2012-02-06 08:25:27 1
  • If script.sh contains only these two lines: $ uname -a $ whoami Show Sample Output


    4
    bash -x script.sh
    unixmonkey8024 · 2010-12-15 17:01:51 0

What Others Think

This is a colossally bad idea. Never, ever do this. Download the script first, then examine it to make sure it's not going to do anything horrible like delete the contents of your root file system or install some backdoor software. Seriously, just don't.
snegtul · 170 weeks and 5 days ago
This is a colossally bad idea. Never, ever do this. Download the script first, then examine it to make sure it's not going to do anything horrible like delete the contents of your root file system or install some backdoor software. Seriously, just don't.
snegtul · 170 weeks and 5 days ago
commandlinefu.com is broken again. Lots of 502s after logging in and/or after submitting a comment.
snegtul · 170 weeks and 5 days ago
Really, this is a horrible idea. Don't ever encourage other people to do this. I don't care how many popular GitHub projects have "curl github/blah/install.sh | sh -c" as their installation instructions. Don't do it! It's like telling a Windows user to run a random executable from example.com/hotdownloads without even running an antivirus scan on it first.
alphapapa · 166 weeks and 4 days ago
What if I do for my own scripts and automation processes, which I trust? People run installers without knowing what is their souce code and how they would affect the system, so what's the difference? I thought this site was not for beginners, and I presume people would use wisely the codes they found here.
paulera · 166 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: