[Tutor] help How do I use a program I built in linux (fwd)

alan.gauld@bt.com alan.gauld@bt.com
Fri, 4 Oct 2002 17:14:26 +0100


> > I figured out how to run the programs, but if I make a new 
> > directory for my programs... I type the path of the file 
> > for example python begpythonnow.py...  

One thing about Unix(including Linux) is that you don't 
need the python at the front provided you start tyour 
script with the "shebang trick"

That means that you put the following magic line at the start:

#! /bin/env python
# rest of script foo.py here....

Save the file and change it to be executable:

$ chmod +x foo.py

And then you can run your file directly by just typing 

$ foo.py

( Or double clicking in a file explorer GUI application. )

You can still type

$ python <path to foo>/foo.py

if you want to but its easier to just type:

$<path to foo>/foo.py

HTH,

Alan g.
Author of the 'Learning to Program' web site
http://www.freenetpages.co.uk/hp/alan.gauld