On 7-Aug-08, at 9:45 AM, Mike Covill wrote:

On 7-Aug-08, at 9:34 AM, Pascal Bompard wrote:

Returning to this 3 week old chestnut, (apologies for delay - my second child was born in the interim), and thanks to all who attempted to help, but I am still struggling with this issue.

Christopher Barker wrote:
If you have scripts you want to run from anywhere, make them executable:

This is exactly what I need to occur with this particular script

chmod a+x MyScript.py

permissions are set to 755 (i.e. full permissions)

and put:  #!usr/bin/env python   at the top.

yes, that is in place

Then either:

put them in a standard place that should be on your PATH, like:

/usr/local/bin

or put the path to your scripts in your PATH -- often people use:

~/bin

I actually have this in my PATH,
/Users/pascal/Documents/Python/Dev/myapp

and with all the above I get:

Administrator:~ pascal$ python test.py
/System/Library/Frameworks/Python.framework/Versions/2.5/Resources/ Python.app/Contents/MacOS/Python: can't open file 'test.py': [Errno 2] No such file or directory

whereas calling the script from within it's parent directory does work.

What could I possibly be doing wrong here?

Your PATH is only used to find the executable (python), not the document (test.py). The document must include either the relative path from where you are, or the absolute path.

You should be able to execute your script by typing just your script name from anywhere, leave out "python":

Administrator:~ pascal$ test.py

in this case test.py is the 'executable', and your system will look for it using your PATH setting.

Mike




do buy a book or surf the web for info about using the terminal on OS-X -- it's a great skill to have.

You're right. I have recently acquired a great book called "From Bash to Z-Shell", but it's tough to retain all the tricks when I use the terminal so seldom.



-Chris

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[EMAIL PROTECTED]
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to