How to distribute my Python / shell script?

I have written a very simple command line utility for myself. The setup consists of:

  • One .py file containing the application / source.
  • One executable shell (chmod + x) script that runs python script.
  • A line in my .bash_profile that pseudonizes my command as follows: alias cmd='. shellscript'(This way it works in the same terminal context.)

So I can type cmdto run it, and everything works fine.

My question is, how can I spread this to others? Obviously, I could just write these instructions with my code and do with it, but is there a faster way? I sometimes saw these single-line liners that you insert into the console to install something. How should I do it? I seem to recall them involving curland piping up sh, but I can't remember.

+5
source share
2 answers

Download the script to something like ideone . Then tell your friend to connect it to python. Sample script:

def print_message():
    print "This is my very special script!"

if __name__ == "__main__":
    print_message()

Script run example:

username@server:~$ curl http://ideone.com/plain/O2n3Pg 2>/dev/null | python
This is my very special script!
+3
source

chmod + x cmd.py

then they can print. /cmd.py

they can also use it for channel transmission.

, unix, , , , , , - .

, , python script.

+1

All Articles