An Intro to
Programming
with Python

Fall 2006
course
navigation

running programs from the command line

unix

First create hi_there.py.
Then, from the command line, in the same directory (which I use "ls" to confirm), make it executable and run it.
mdhcp11:~/Desktop mahoney$ ls hi_there.py stuff mdhcp11:~/Desktop mahoney$ chmod +x hi_there.py mdhcp11:~/Desktop mahoney$ l total 8 8 hi_there.py* 0 stuff/ mdhcp11:~/Desktop mahoney$ ./hi_there.py Hi there mdhcp11:~/Desktop mahoney$
Related command line stuff :
$ ls -a # list all files, including ones starting with "." $ ls -al # list all files, long form (including permissions) $ echo $PATH # print out my PATH variable $ export PATH=$PATH:. # add current directory to my search PATH
The file ~/.bashrc ("~" is the name of your home directory) contains shell script stuff that runs each time you log in, so that's the place to set your PATH once and for all, or to set alias to commony used commands, e.g.
$ alias l="ls -sCF"
http://cs.marlboro.edu/ courses/ fall2006/python/ wiki/ running_programs_from_the_command_line
last modified Wednesday September 20 2006 11:35 am EDT