Running Python on Gentoo

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Running Python on Gentoo

Greg Lindstrom-2
Hello,
I am running python 2.4.2 on Gentoo Unix and am having problems running
programs.  I have a script, hello.py as such:

#! /usr/bin/python
print 'hello, world'

that I save and add executable permission.  Then at the prompt I type in..

$ ./hello.py
-bash: ./hello.py: /usr/bin/python: bad interpreter: Permission denied

If I type
$ python hello.py
I get "hello, world" as expected.

I was hoping that the "shabang" would have the script execute.  Am I
missing something?  Can you help me?  BTW, when I type /usr/bin/python
at the prompt I get the python interpreter, so at least that's working.

Thanks,
--greg

_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: Running Python on Gentoo

Khamid Nurdiev
Yes, I have the same problem with running python scripts from console in Debian, the line "#! /usr/bin/python" doesn't help. I have to type "python script.py" in order to run the script.py file.

On 7/26/07, Greg Lindstrom <[hidden email]> wrote:
Hello,
I am running python 2.4.2 on Gentoo Unix and am having problems running
programs.  I have a script, hello.py as such:

#! /usr/bin/python
print 'hello, world'

that I save and add executable permission.  Then at the prompt I type in..

$ ./hello.py
-bash: ./hello.py: /usr/bin/python: bad interpreter: Permission denied

If I type
$ python hello.py
I get "hello, world" as expected.

I was hoping that the "shabang" would have the script execute.  Am I
missing something?  Can you help me?  BTW, when I type /usr/bin/python
at the prompt I get the python interpreter, so at least that's working.

Thanks,
--greg

_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor


_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: Running Python on Gentoo

Eric Brunson

What does the command "which python" say?

Khamid Nurdiev wrote:

> Yes, I have the same problem with running python scripts from console
> in Debian, the line "#! /usr/bin/python" doesn't help. I have to type
> "python script.py" in order to run the script.py file.
>
> On 7/26/07, *Greg Lindstrom* <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hello,
>     I am running python 2.4.2 on Gentoo Unix and am having problems
>     running
>     programs.  I have a script, hello.py as such:
>
>     #! /usr/bin/python
>     print 'hello, world'
>
>     that I save and add executable permission.  Then at the prompt I
>     type in..
>
>     $ ./hello.py
>     -bash: ./hello.py: /usr/bin/python: bad interpreter: Permission denied
>
>     If I type
>     $ python hello.py
>     I get "hello, world" as expected.
>
>     I was hoping that the "shabang" would have the script execute.  Am I
>     missing something?  Can you help me?  BTW, when I type /usr/bin/python
>     at the prompt I get the python interpreter, so at least that's
>     working.
>
>     Thanks,
>     --greg
>
>     _______________________________________________
>     Tutor maillist  -  [hidden email] <mailto:[hidden email]>
>     http://mail.python.org/mailman/listinfo/tutor
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tutor maillist  -  [hidden email]
> http://mail.python.org/mailman/listinfo/tutor
>  

_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: Running Python on Gentoo

Greg Lindstrom-2
Eric Brunson wrote:
>
> What does the command "which python" say?
glindstrom@bender ~ $ which python
/usr/bin/python

HTH,
--greg


_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: Running Python on Gentoo

Eric Brunson
Greg Lindstrom wrote:

> Eric Brunson wrote:
>  
>> What does the command "which python" say?
>>    
> glindstrom@bender ~ $ which python
> /usr/bin/python
>
> HTH,
> --greg
>
>
>  

Wow, Gentoo sucks more than I thought.  ;-)

I can't think of why that wouldn't work, unless you have some odd,
non-printing character at the end of your interpreter line.

Do other interpreters work?

Try:

#!/usr/bin/perl
print "Perl Sucks!!!\n";

or:

#!/usr/bin/expect
puts "I hate TCL"


_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: Running Python on Gentoo

Dave Kuhlman
On Thu, Jul 26, 2007 at 01:48:44PM -0600, Eric Brunson wrote:
>
> Do other interpreters work?
>
> Try:
>
> #!/usr/bin/perl
> print "Perl Sucks!!!\n";
>
> or:

Or, try:

    #!/usr/bin/env python

Dave

--
Dave Kuhlman
http://www.rexx.com/~dkuhlman
_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: Running Python on Gentoo

David Rock
In reply to this post by Greg Lindstrom-2
* Greg Lindstrom <[hidden email]> [2007-07-26 13:44]:

> Hello,
> I am running python 2.4.2 on Gentoo Unix and am having problems running
> programs.  I have a script, hello.py as such:
>
> #! /usr/bin/python
> print 'hello, world'
>
> that I save and add executable permission.  Then at the prompt I type in..
>
> $ ./hello.py
> -bash: ./hello.py: /usr/bin/python: bad interpreter: Permission denied
>
> If I type
> $ python hello.py
> I get "hello, world" as expected.
>
> I was hoping that the "shabang" would have the script execute.  Am I
> missing something?  Can you help me?  BTW, when I type /usr/bin/python
> at the prompt I get the python interpreter, so at least that's working.

Are you using any hardened gentoo kernels or anything like that, or is
it a "normal" gentoo build?

I don't think this is a python problem, but rather a permissions problem
at a level OTHER than the filesystem.

I found this in the gentoo forums:
http://forums.gentoo.org/viewtopic-t-549470-highlight-interpreter+permission+denied.html

Are you using any "trusted path execution" in the kernel?  This would
potentially be something that could happen with ANY lniux system, not
just gentoo.

FWIW, I am having the same problem (even though I never actually tried
on this system before) :-)

--
David Rock
[hidden email]
_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: Running Python on Gentoo

David Rock
Just to follow up on what _my_ environment looks like (and the probable
cause in my case, anyway)

Security Options ->
GRsecurity ->
Executable Protections ->
Trusted Path Execution (TPE)

CONFIG_GRKERNSEC_TPE:
If you say Y here, you will be able to choose a gid to add to the
supplementary groups of users you want to mark as "untrusted." These
users will not be able to execute any files that are not in root-owned
directories writable only by root.  If the sysctl option is enabled, a
sysctl option with name "tpe" is created.  

Now I just need to find how to turn that off. I did want it more secure :-)

--
David Rock
[hidden email]
_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor