Python execution problem

M

mailpitches

Using OSX 10.4.5

This is more of a unix/tcsh question than a python question.
Somehow I got to the point where I have two files 'a.py' and 'b.py'
which have identical contents and permissions, but one refuses to
execute:

[blah:/Library/WebServer/CGI-Executables] me% a.py
tcsh: a.py: Command not found.
[blah:/Library/WebServer/CGI-Executables] me% b.py
okay
[blah:/Library/WebServer/CGI-Executables] me%

Could someone enlighten me about how the shell knows to execute a
script? I always assumed it was just the extension, but this seems to
prove me wrong.

tnx>mp
 
J

Jeffrey Schwab

Using OSX 10.4.5

This is more of a unix/tcsh question than a python question.
Somehow I got to the point where I have two files 'a.py' and 'b.py'
which have identical contents and permissions, but one refuses to
execute:

[blah:/Library/WebServer/CGI-Executables] me% a.py
tcsh: a.py: Command not found.
[blah:/Library/WebServer/CGI-Executables] me% b.py
okay
[blah:/Library/WebServer/CGI-Executables] me%

Could someone enlighten me about how the shell knows to execute a
script? I always assumed it was just the extension, but this seems to
prove me wrong.

It checks each directory in your path for an executable file with the
name you specified. Each file has a set of associated bits to tell
whether it is executable (or readable or writable), and by whom. To add
execute permission to a.py, try this:

chmod +x a.py

FYI, it's not a great idea to rely on the current directory (.) being in
your path. You might want to type it explicitly, e.g ./a.py instead of
a.py.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top