Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

i am having a python script

#!/usr/bin/env python

in top of my script? following is the permission i had set

-rwxr-xr-x 1 user1 user2 6423 Nov 15 15:12 test

i tried executing the script as user1 ./test its giving me permission denied?

when i do

whoami it shows user1 and umask is 0022, user1 has bash as his default shell

$python test (it works fine)

Any ideas??

share|improve this question
    
Are you running this on a volume with the mount option noexec? –  gertvdijk Nov 15 '12 at 10:49
    
@gertvfijk No if that is the case the script wont execute when i try python script name. –  LINUX4U Nov 15 '12 at 11:01
    
Untrue. # ./testscript.py -su: ./testscript.py: Permission denied and # python testscript.py bla –  gertvdijk Nov 15 '12 at 11:08
add comment

3 Answers

I remember an issue like that because I had a test.pyc in the same directory, and interpreter was using it instead of the original interpreted one (test.py). Maybe it's a lead for you.

share|improve this answer
    
thanks, but my org script name is different, for posting in the forum i used test script name is fsetup :-( –  LINUX4U Nov 15 '12 at 12:13
add comment

When you mention #!/usr/bin/env python in first line, it looks for python from $PATH.

Type which python and check whether the path from the output is added to $PATH. If not add it.

  • export PATH="$PATH:/usr/local/bin/python"

For more information about setting the PATH variable refer this page

share|improve this answer
    
i am having another script that is set up with same path to python interpretor, that will execute fine with ./script2 but the errror only happens to test script, i dont know what the problem is..is there anything other that PATH i need to look into –  LINUX4U Nov 15 '12 at 11:14
    
No. When you say the other scripts work fine with the same setup. I don't think the problem is with $PATH –  devav2 Nov 15 '12 at 12:04
add comment

I never ever use names as test as my scriptname. Likewise for simple names as time, date, parser, etc unless in a package with absolute imports, and even then it's bad practice. These names are too likely to interfere with either installed modules or other scripts/packages in your working directory and/or path.

Conclusion: check if you don't have a folder called test in the same directory.

share|improve this answer
    
test is the name that i had use to post in the form the script name is different it is fsetup –  LINUX4U Nov 15 '12 at 12:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.