When do we need chmod + x file.py

I wrote a py script to extract the page from the Internet, it just read the write permission enough, so my question is when do we need permission to execute?

+4
source share
3 answers

This needs to be done if you need to run the script as follows: ./file.py . Keep in mind that you need to put the python path at the very top of the script: #!/usr/bin/python .

But wait, you need to make sure you have the right path to accomplish this: which python .

+4
source

Reading / writing 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, for example. ./file.py , then you need permission to execute (and the corresponding hash line at the top).

+6
source

If you want to be able to run it directly with $ file.py , you will need a run bit. Otherwise, you can run it with $ python file.py

0
source

All Articles