LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Linux won't recognize shebang line (https://www.linuxquestions.org/questions/linux-general-1/linux-wont-recognize-shebang-line-49900/)

tjanzer 03-14-2003 07:46 PM

Linux won't recognize shebang line
 
Hi,
I was hoping someone could help me with a strange situation:

I have a Red Hat Linux 8 installation, all the standard stuff, including perl and am using the bash shell.

I wrote the standard "Hello World" Perl program and attempted to execute it with the command:
> hello.pl

The shell replies:
-bash: hello.pl: command not found

The shebang line at the top of the program says:
#!/usr/bin/perl

And the command: which perl tells me:
/usr/bin/perl

The file permissions are: -rwxrwxr-x

The programs does run correctly with the command:
> perl hello.pl

I have also used hexdump to look at hello.pl and ensure that it has only newlines (\n) at the end of the lines and not any extraneous carriage returns (\r).

I hope that is enough info to show that I have investigated all the ordinary things that go wrong, but I am still stumped.

BTW: I have also tried running this under bash2, csh and sh ... with the same results. This happens with any .pl or .cgi programs I try to run. All the programs I have also tested on other Unix systems and they run fine.

Please help if you can. Thanks.

Capt_Caveman 03-14-2003 09:35 PM

If you're in the same directory as the file then run it using:
./hello.pl
Perl should then do the rest!

tjanzer 03-15-2003 10:33 AM

Thank you Capt_Caveman! That did it.

Oh the explicitness of it all! I'd always heard that one of Linux' strengths was that fact that it was so highly configurable. Apparently that extends to where it looks for a command you tell it to run.

I have added .: to my path in .bash_profile and Perl is a happy camper again!


All times are GMT -5. The time now is 11:18 PM.