Python and Red Hat Linux 6.0 
Author Message
 Python and Red Hat Linux 6.0

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?


Fri, 11 Jan 2002 03:00:00 GMT  
 Python and Red Hat Linux 6.0
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?


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

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?

Every decent Unix supports #! shell scripts. Linux is one of them. As far as I
understand it, #! is just a different magic number that allows the kernel's
binary format handlers to detect the script in the same way that 0x7f then
"ELF" marks an elf executable.

If you're interested, check out
  /usr/src/linux/fs/binfmt_script.c
When an image is exec'ed, the kernel applies all the binary format handlers it
knows in succession, until one works.

As for your problem:

1)      Check your PATH. If . is not in your path, you have to run the script
        as ./scriptname
        This is my best guess as to your problem, given your symptoms.

2)      Check your script. It's easy to write !#/usr/bin/python by accident,
        with your mind moving faster than your fingers. But for this problem
        you get different errors.

3)      chmod +x scriptname
        However, this will give you "Permission denied." if you forget. This is
        a common problem, especially if you use an editor which resets the
        permissions whenever you save.

--



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

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?

I also recently had a similar problem, I had created the
files using Wordpad and saved them to the Linux server.  I
thought I was using a UNIX-safe text format, but I later
discovered it was in DOS text format.  Just another idea.


Mon, 21 Jan 2002 03:00:00 GMT  
 Python and Red Hat Linux 6.0

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?

Did you do `chmod +x' on the file?
Did you start it with `./script', or did you start it with `script'?

On RH, the current directory `.' is not in your path by default
for security reasons, so you have to mention the path explicitely.

BTW, it's not the shell that interprets the `#!...' line.
It's the kernel. (If it was just the shell, it would be just as
useless as those braindead Windows "shortcuts", sorry for the rant.)

Greetings,

Stephan



Tue, 22 Jan 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Python and Red Hat Linux 6

2. strange ImportError on Red Hat Linux python installation

3. Where is Red Hat Linux 4.0 python documentation?

4. Intel FORTRAN 6.0 on Red Hat 7.2

5. Forth RPM for Red Hat Linux

6. Font display problems under Red Hat Linux 7.3

7. Various Ruby RPMs available for Red Hat Linux 7.2

8. FLORIST-2.0 on Red Hat Linux 5.0

9. Obtaining the IDLE GUI under Red Hat Linux 7.2

10. _imaging.so for Red Hat Linux needed

11. pgplot Windows NT and Red Hat LINUX

12. Red Hat Linux and poplib.py

 

 
Powered by phpBB® Forum Software