'!#' script interpreter convention ...

From: Saurabh Verma (saurabh_verma78_at_yahoo.com)
Date: 04/29/03


Date: 28 Apr 2003 17:16:10 -0700

Hi,
I have some confusion regarding usage of '#!' at the first line of any
executable script. 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??

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.

Thanks a lot ...
Saurabh



Relevant Pages

  • Obtaining complete Unix command line that evoked script as string
    ... If there is a more appropriate list for this, let me know; the other perl lists I've seen seem to specialised for this. ... Note this is not just the arguments of the call to the script, but everything including pipes and redirects, etc., e.g. ... Ideally the perl interpreter would grab the complete command line as its evoked and I'd access this via a variable. ...
    (perl.beginners)
  • Re: Displaying a users group memberships
    ... The user's username is passed to the script via the command line and captured with ARGV. ... I want to determine the group memberships (much like executing `groups` from the command line) and run those through a loop for processing. ... I'm very new to Perl so maybe I'm just looking for the wrong terms or something. ... The format of the command is simple: `test.pl username`, where username is a real username on the system in question. ...
    (perl.beginners)
  • Re: "register" (in perl scripts)
    ... scripted gimp. ... This is a Perl problem, not a GIMP problem so you would probably ... it looks to me like you're trying to execute a command ... By the way, your script doesn't appear to use any CGI, etc. - at ...
    (comp.graphics.apps.gimp)
  • Re: Linux
    ... You almost certainly have Perl already installed. ... But the actual command line interpreter should be the same between them. ... put the shebang line as the first line of the script. ... You can then execute the program ...
    (perl.beginners)
  • RE: Humble questions for web developers in freebsd.
    ... If it has X permissions for available ... > interpret the script. ... > perl" to find out the path to perl on your system and use ... there to protect yourself from running the wrong command. ...
    (freebsd-questions)