I've set up a site to post scripts to which I can then execute later using the following command:
curl -so /tmp/script http://scripts.programster.org/scripts/1?output=raw && . /tmp/script
This example script outputs "hello world" to the terminal.
As you can see, that's rather long and messy and risks overwriting a user's file if they just happen to have a file called
/tmp/script. I used to just pipe to bash like so:
curl -s http://scripts.programster.org/scripts/1?output=raw | bash
However, I want the command to work with scripts written in other languages such as PHP (using
#!/usr/bin/php at the top of the script), hence the change to the first command.
Is there a way that I can execute an online script without having to save it to the local filesystem, whilst also not knowing what program to execute it in beforehand? Perhaps there is a way to treat a url like a file which would allow me to do something like: