Hey guys.
So, I have a Python script. Let’s call it “Pythonfile.py” (Wow, I have so much imagination xD)
I would usualy run it by typing in:
$ python ~/Desktop/Pythonfile.py -arg1 arg2 arg3
Now, this is kinda bothering; having to type all the python things. Idealy, I would want to run it like:
$ pythonfile -arg1 arg2 arg3
This would mean adding a new command to bash. But how? I would guess you should put a file:
/usr/bin/pythonfile
But what should be inside? I want it to run the original python script, which is located on the desktop – AND WITH THE ARGUMENTS .I’m on Ubuntu 10 by the way.
Don’t place the command in
/usr/binunless it is meant to be run by all users. Place it in~/bininstead, and modify thePATHenvironment variable to search for executables there, by adding this to yout~/.bashrcfile:As to the contents of the (now)
~/bin/pythonfile, you may use:The first line tells
bashthe file is a bash script, and the second line executes the python script.You can also set
#!/usr/bin/env pythonas the first line of the Python script, move the script to~/bin, make it executable, and the run it as:Something I like to do with that second option is to add a symbolic link to avoid having to type the
.pypart: