Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a python script become a unix command?

How do I make a python script a unix-able command?

Let's say i have a python script:

print "hello foo bar"

and i want to call the python script like a normal linux command, something that people can:

deb www.myfoobar.com foobar
deb-src www.myfoobar.com foobar
sudo apt-get install foobar

Then after installation, something that someone can just call from terminal:

$ foobar
hello foo bar
like image 403
alvas Avatar asked Mar 19 '26 20:03

alvas


1 Answers

Put following shebang line at the top of the script.

#!/usr/bin/env python

Make a script executable using following command:

chmod +x foobar

Move the script to somewhere in the $PATH (for example: /usr/local/bin)

mv foobar /usr/local/bin

From Rob: For the creating and hosting a deb problem, you can use external services such as https://launchpad.net/ubuntu

like image 84
falsetru Avatar answered Mar 22 '26 09:03

falsetru