[Tutor] python scripting using "./"

Walter Prins wprins at gmail.com
Tue May 24 16:39:16 CEST 2011


Hi Hank,

On 24 May 2011 15:15, Hank Wilkinson <hwilkinson at triad.rr.com> wrote:

> Yes, I would love to know why it doesn't work, or what I'm doing wrong.
>
> John-Wilkinsons-iMac:p31summerfield wilkinson$ cat hello.py
> #!/usr/bin/env python
>
> print("Hello world")
> John-Wilkinsons-iMac:p31summerfield wilkinson$ chmod +X hello.py
> John-Wilkinsons-iMac:p31summerfield wilkinson$ ./hello.py
> -bash: ./hello.py: Permission denied
>

OK you had me scratching my head for a couple of minutes, but then I tried
your steps on my Ubuntu box and managed to reproduce it.

The problem here is you're using +X (capital X) when setting the file
execute permission.  You should be using +x (lowercase x) when setting the
script to be executable.  Capital X will only set the file to be executable
if it's **already** executable for some other user/group (which is not the
case in your new script's case.)  Lowercase x will set it executable full
stop.

Cheers

Walter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110524/5d590842/attachment.html>


More information about the Tutor mailing list