I have written a very simple command line utility for myself. The setup consists of:
alias cmd='. shellscript'
(So it runs in the same terminal context.)So effectively I can type cmd
to run it, and everything works great.
My question is, how can I distribute this to others? Obviously I could just write out these instructions with my code and be done with it, but is there a faster way? I've occasionally seen those one-liners that you paste into your console to install something. How would I do that? I seem to recall them involving curl
and piping to sh
but I can't remember.
Upload your script to something like ideone. Then tell your friend to pipe it into python
. Example script:
def print_message():
print "This is my very special script!"
if __name__ == "__main__":
print_message()
Example of running script:
username@server:~$ curl http://ideone.com/plain/O2n3Pg 2>/dev/null | python
This is my very special script!
chmod +x cmd.py
then they can type ./cmd.py
they can also use it piped.
I would add that unix users would probably already know how to make a file executable and run it, so all you'd have to do is make the file available to them.
Do make sure they know what version(s) of python they need to run your script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With