Re: '!#' script interpreter convention ...

From: John DuBois (spcecdt_at_deeptht.armory.com)
Date: 04/29/03


Date: 29 Apr 2003 00:26:08 GMT

In article <58c50fc8.0304281616.538e31ee@posting.google.com>,
Saurabh Verma <saurabh_verma78@yahoo.com> wrote:
>I am writing a perl script(say 'test.pl'), with
>first line as '#!perl', but when i am running command 'test.pl' on
>command line, getting the following error:
>test.pl: Command not found.
>I am using tcsh shell, on solaris platform.
>whereas running 'perl test.pl' is woking.
>Or, if i replace the first line with '#!/usr/local/bin/perl', then
>also its woking.
>So, do i need to give the full path of the executable on the first
>line??

Yes.

>Till now, i had the understanding that '#!interpreter args' in the
>first line of a script will lead the shell to run command 'interpreter
>args script-file', that in my case is 'perl test.pl'(which is working
>fine, when i am running it from command line).
>
>Can somebody tell me, how exactly '#!' is handled by a shell in
>general and by tcsh in this specific case.

It isn't handled by the shell, it's handled by the kernel. The shell at most
looks at the #! line and notes that this isn't a program that it should handle
by forking and interpreting itself. After making that determination, it exec's
the program, and it is the kernel that interprets the #! line.

        John

-- 
John DuBois  spcecdt@armory.com  KC6QKZ/AE  http://www.armory.com/~spcecdt/


Relevant Pages

  • Shell::Jobs - request for comments
    ... In an effort to make the code developed for the Zoidberg shellmore ... perl shells. ... # Run a shell command in the background ...
    (comp.lang.perl.modules)
  • Re: Completed my programming language overview with a BASIC for CP/M page also
    ... opinion on bywater basic - their should be a cp/m version ... The Bywater BASIC Interpreter implements a large ... It also offers shell programming facilities ... a shell command can be entered interactively at the ...
    (comp.os.cpm)
  • Re: Switching from tcsh to bash as an interactive shell
    ... > Every shell is, by definition, an interpreter. ... A PRGRAMMING LANGUAGE - some of them are command launchers and nothing ... as it may be as an interpreter of its own programming language. ...
    (comp.os.linux.misc)
  • Re: Switching from tcsh to bash as an interactive shell
    ... > Every shell is, by definition, an interpreter. ... A PRGRAMMING LANGUAGE - some of them are command launchers and nothing ... as it may be as an interpreter of its own programming language. ...
    (comp.unix.shell)
  • Re: perl program with "&"
    ... This is an excellent suggestion. ... IW> it is a shell error message. ... This means that this isn't really a perl question. ... IW> I'd try typing your command into a shell command line before embedding ...
    (comp.lang.perl.misc)