Python and Red Hat Linux 6 
Author Message
 Python and Red Hat Linux 6

Quote:

> When programming in Perl or Python, I am using a header like the
> following on an executable file to cause the shell (bash or csh) to run
> the scripts as Perl/Python files:
> #!/usr/bin/perl   for Perl   and #!/usr/bin/python   for Python. I've
> checked and the compilers are located in the appropriate directories. I
> keep getting this when I run scripts:
> bash: <script name>: command not found. Does Linux support the '#!'
> notation in the file header, or do I always have to run the scripts by
> explicitly typing in 'perl' or 'python' before the script name?
> ~Rob~

Try

!#/usr/bin/env python

instead (don't ask me why, i read it in a FAQ somewhere :-)

--                                                            
Brian Pedersen, M.Sc.E.E.                         /\              
DSP Software and Algorithm Development       .~. /  \ .~.
URL: http://www.*-*-*.com/ ~kibria/brian/        ~    ~
NOTE: New e-mail address !



Fri, 11 Jan 2002 03:00:00 GMT  
 Python and Red Hat Linux 6
When programming in Perl or Python, I am using a header like the
following on an executable file to cause the shell (bash or csh) to run
the scripts as Perl/Python files:
#!/usr/bin/perl   for Perl   and #!/usr/bin/python   for Python. I've
checked and the compilers are located in the appropriate directories. I
keep getting this when I run scripts:
bash: <script name>: command not found. Does Linux support the '#!'
notation in the file header, or do I always have to run the scripts by
explicitly typing in 'perl' or 'python' before the script name?
~Rob~


Fri, 11 Jan 2002 03:00:00 GMT  
 Python and Red Hat Linux 6
that sound right.. did you set the file to be executable (chmod?)

Quote:

> When programming in Perl or Python, I am using a header like the
> following on an executable file to cause the shell (bash or csh) to run
> the scripts as Perl/Python files:
> #!/usr/bin/perl   for Perl   and #!/usr/bin/python   for Python. I've
> checked and the compilers are located in the appropriate directories. I
> keep getting this when I run scripts:
> bash: <script name>: command not found. Does Linux support the '#!'
> notation in the file header, or do I always have to run the scripts by
> explicitly typing in 'perl' or 'python' before the script name?
> ~Rob~

--
----------------------------------------------------------------



Fri, 11 Jan 2002 03:00:00 GMT  
 Python and Red Hat Linux 6

Quote:

> When programming in Perl or Python, I am using a header like the
> following on an executable file to cause the shell (bash or csh) to run
> the scripts as Perl/Python files:
> #!/usr/bin/perl   for Perl   and #!/usr/bin/python   for Python. I've
> checked and the compilers are located in the appropriate directories. I
> keep getting this when I run scripts:
> bash: <script name>: command not found.

did you try:

$ ./scriptname

if this works, check your PATH settings (having "."
in the path is usually considered a bad idea, but it's
your computer ;-)

</F>



Fri, 11 Jan 2002 03:00:00 GMT  
 Python and Red Hat Linux 6
Yeah, using #!/bin/env/python should help, but Red Hat should support
pound-bang (#!) anyway. You might want to check in with tech support.


Quote:

> > When programming in Perl or Python, I am using a header like the
> > following on an executable file to cause the shell (bash or csh) to run
> > the scripts as Perl/Python files:
> > #!/usr/bin/perl   for Perl   and #!/usr/bin/python   for Python. I've
> > checked and the compilers are located in the appropriate directories. I
> > keep getting this when I run scripts:
> > bash: <script name>: command not found. Does Linux support the '#!'
> > notation in the file header, or do I always have to run the scripts by
> > explicitly typing in 'perl' or 'python' before the script name?
> > ~Rob~

> Try

> !#/usr/bin/env python

> instead (don't ask me why, i read it in a FAQ somewhere :-)

> --
> Brian Pedersen, M.Sc.E.E.                         /\
> DSP Software and Algorithm Development       .~. /  \ .~.
> URL: http://www.danbbs.dk/~kibria/brian/        ~    ~
> NOTE: New e-mail address !



Fri, 11 Jan 2002 03:00:00 GMT  
 Python and Red Hat Linux 6
Yes, Linux supports #!.  Sounds like /usr/bin/python doesn't exist or
perhaps is not executable.

Bill



Sat, 12 Jan 2002 03:00:00 GMT  
 Python and Red Hat Linux 6
On Mon, 26 Jul 1999 21:40:18 GMT, Brian Pedersen

Quote:

>Try

>!#/usr/bin/env python

>instead (don't ask me why, i read it in a FAQ somewhere :-)
>--                                                            
>Brian Pedersen, M.Sc.E.E.  

I have the same problem and this solution won't works. If you type

$ file.py
bash: ./file.py : Command not found

is a normal behaviour. But the correct syntax should be

$ ./file.py

but the output is

bash: file.py : Permission denied

Any good solution?

Marco



Sat, 12 Jan 2002 03:00:00 GMT  
 Python and Red Hat Linux 6

Quote:

> I have the same problem and this solution won't works. If you type

> $ file.py
> bash: ./file.py : Command not found

file.py is not in your PATH and isn't found.

Quote:
> $ ./file.py

> but the output is

> bash: file.py : Permission denied

Now you've specified the path, and file.py is found, but you
haven't made the file executable.

chmod u+x file.py
./file.py

Quote:
> Any good solution?

man chmod
:)

-------------------------------------------
Tom Bryan
Applied Research Laboratories
University of Texas at Austin



Sat, 12 Jan 2002 03:00:00 GMT  
 Python and Red Hat Linux 6

Quote:


> > I have the same problem and this solution won't works. If you type

> > $ file.py
> > bash: ./file.py : Command not found

> file.py is not in your PATH and isn't found.

No, no, that would make sense; you get an error like this if file.py is
found and is executable and has a first line of the form

#!/path/to/executable

and /path/to/executable doesn't exist.

HTH
Michael



Sat, 12 Jan 2002 03:00:00 GMT  
 Python and Red Hat Linux 6


Quote:
> !#/usr/bin/env python

> instead (don't ask me why, i read it in a FAQ somewhere :-)

You have to give #! an absolute pathname for it to work.  env is
(somewhat) reliably at /usr/bin and is a program used exclusively for
running other programs in certain environments.  In this case, it is used
because it will search your path for python rather than requiring it to be
explicit.

----------------------------------
Nathan Clegg



Sat, 12 Jan 2002 03:00:00 GMT  
 Python and Red Hat Linux 6
Excerpts from ext.python: 27-Jul-99 Re: Python and Red Hat Linux 6

Quote:
> You have to give #! an absolute pathname for it to work.  env is
> (somewhat) reliably at /usr/bin and is a program used exclusively for
> running other programs in certain environments.  In this case, it is used
> because it will search your path for python rather than requiring it to be
> explicit.

Of course, it only works if python is on the PATH of the program
executing the script.  Personally, I don't find the /usr/bin/env hack
useful.

Bill



Sat, 12 Jan 2002 03:00:00 GMT  
 Python and Red Hat Linux 6

  >> You have to give #! an absolute pathname for it to work.  env is
  >> (somewhat) reliably at /usr/bin and is a program used exclusively
  >> for running other programs in certain environments.  In this
  >> case, it is used because it will search your path for python
  >> rather than requiring it to be explicit.

  Bill> Of course, it only works if python is on the PATH of the
  Bill> program executing the script.  Personally, I don't find the
  Bill> /usr/bin/env hack useful.

It used to be more useful when python tended to be in /usr/local/bin
rather than /usr/bin which is now the case on most Linux boxes. The
env hack also has the disadvantage that it doesn't let you pass
through the -O option to the python interpreter (at least under
Linux). This is the case on various other flavours of unix as well,
which is why perl reparses the first line of the perl script to get
the options instead of relying on what it was given as argv.

This topic seems to come up rather regularly. As always, I strongly
suggest people read "man perlrun" and "man tclsh" to get a good
understanding of the pro's and con's of the various methods. Maybe
this is for the FAQ?

 - Andrew thought-it-was-already-in-there Snare
--
#!/usr/bin/env python
print(lambda s:s+"("+`s`+")")\
('#!/usr/bin/env python\012print(lambda s:s+"("+`s`+")")\\\012')
print(lambda x:x%`x`)('print(lambda x:x%%`x`)(%s)')



Sun, 13 Jan 2002 03:00:00 GMT  
 Python and Red Hat Linux 6

Quote:

> On my Red Hat 6.0 system, problems #1 and #2 report an identical
> error message.  I lost track of the thread, but I meant to suggest
> that if one has already checked #2, then he should also check #2.

ummm...oops....that should be "then he should also check #1"

Quote:
> the-gremlins-have-been-modifying-my-PATH-ly yours

the-gremlins-have-been-modifying-my-news-posts-ly yours

-------------------------------------------
Tom Bryan
Applied Research Laboratories
University of Texas at Austin



Sun, 13 Jan 2002 03:00:00 GMT  
 Python and Red Hat Linux 6

Quote:



> > > I have the same problem and this solution won't works. If you type

> > > $ file.py
> > > bash: ./file.py : Command not found

> > file.py is not in your PATH and isn't found.

> No, no, that would make sense; you get an error like this if file.py is
> found and is executable and has a first line of the form

> #!/path/to/executable

> and /path/to/executable doesn't exist.

I think I may have misread the post and answered somewhat hastily.
The point I was trying to make was:
1. Make sure the file containing the python script is in your PATH
   or supply an absolute path to that file.
2. Make sure the #!/path/to/executable actually points to the correct
   executable.
3. Make sure the file containing the python script is executable.

On my Red Hat 6.0 system, problems #1 and #2 report an identical
error message.  I lost track of the thread, but I meant to suggest
that if one has already checked #2, then he should also check #2.

the-gremlins-have-been-modifying-my-PATH-ly yours
Tom

-------------------------------------------
Tom Bryan
Applied Research Laboratories
University of Texas at Austin



Sun, 13 Jan 2002 03:00:00 GMT  
 Python and Red Hat Linux 6

Quote:

> Yeah, using #!/bin/env/python should help, but Red Hat should support
> pound-bang (#!) anyway. You might want to check in with tech support.

Uhmm ... it is not RedHat, but a shell thing, and if #! didn't work,
neither would #!/bin/env/python.

--
Bill Anderson                                   Linux/Unix Administrator, Security Analyst

My opinions are just that; _my_ opinions.



Fri, 18 Jan 2002 03:00:00 GMT  
 
 [ 17 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Python and Red Hat Linux 6.0

2. strange ImportError on Red Hat Linux python installation

3. Where is Red Hat Linux 4.0 python documentation?

4. Forth RPM for Red Hat Linux

5. Font display problems under Red Hat Linux 7.3

6. Various Ruby RPMs available for Red Hat Linux 7.2

7. FLORIST-2.0 on Red Hat Linux 5.0

8. Obtaining the IDLE GUI under Red Hat Linux 7.2

9. _imaging.so for Red Hat Linux needed

10. pgplot Windows NT and Red Hat LINUX

11. Red Hat Linux and poplib.py

12. Precompiled 1.6 for Red Hat Linux 6.2?

 

 
Powered by phpBB® Forum Software