unix - Python scripts in /usr/bin -
I am writing a pretty basic application in Python (this is only a file at the moment). My question is how do I get it so that Python script can be run in / usr / bin without the .py extension?
For example, instead of running
dragon
from any directory in which it is currently, I want to be able to do the CD
htswap args
thanks in advance!
Just change the file name to .py extension. After that, you must enter the following line at the top of your file:
#! / Usr / bin / env dragon
env
is a small program that sets the environment to execute the correct dragon
interpreter to be done.
You also have to make the file executable with command
chmod a + x htswap
and assign it to / Usr / local / bin
. This is cleaner than / usr / bin
, because the content of that directory is usually managed by the operating system.
Comments
Post a Comment