Sunday, July 25, 2010

to run a pythonscript from ubuntu command line

to run a pythonscript from ubuntu command line

to execute script 'hw.py'
from the command line
in the director of 'hw.py' [i.e. if you entered 'ls' you would see hw.py in the listing)

first, make script executable by granting rights
$ sudo chmod +x hw.py

add the following line to the beginning of the script
#!/usr/bin/python

this instructs the shell to hand the script over to the the python runtime binary,
which is located /usr/bin/python

No comments:

Post a Comment

comment: