views:

59

answers:

3

i wrote a py script to fetch page from web,it just read write permission enough,so my question is when we need execute permission?

A: 

If you want to be able to run it directly with $ file.py then you'll need the execute bit set. Otherwise you can run it with $ python file.py.

Daniel Roseman
+4  A: 

Read/write is enough if you want to run it by typing python file.py. If you want to run it directly as if it were a compiled program, e.g. ./file.py, then you need execute permission (and the appropriate hash-bang line at the top).

Michael E
+2  A: 

It's required to do so if you need to run the script in this way: ./file.py. Keep in mind though, you need to put the path of python at the very top of the script: #!/usr/bin/python.

But wait, you need to make sure you have the proper path, to do that execute: which python.

Ruel
i'm under ubuntu lucid 10.04,use komodo edit,when i create a py file,it will give a shebang like,#!/usr/bin/env pythonis there sth different with #!/usr/bin/python what's common way?
mlzboy
See [this question](http://stackoverflow.com/questions/2429511/why-do-people-write-usr-bin-env-python-on-the-first-line-of-a-python-script). `#!/usr/bin/env python` is more common.
ma3