Neutron Jack has asked for the wisdom of the Perl Monks concerning the following question:
#! /tmp/beta 12345 abcde
#! /usr/bin/perl -wln print scalar reverse if $. > 1;
What actually printed:54321 edcba
"man execve" says that you can't have an interpreter running an interpreter, at least on Red Hat:./alpha: line 2: 12345: command not found ./alpha: line 3: abcde: command not found
execve() executes the program pointed to by filename. filename must be either a binary executable, or a script starting with a line of the form "#! interpreter [arg]". In the latter case, the interpreter must be a valid pathname for an executable which is not itself a script,It seems that Perl was invoked with alpha as an argument, noticed that the #! line didn't mention perl, and helpfully invoked a shell to interpret alpha. Well, heck—what can I do? I want alpha to remain unchanged. Am I forced to write beta in a compiled language? I want to use Perl, of course!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Nested #! interpreters
by chromatic (Archbishop) on Feb 21, 2004 at 20:05 UTC | |
|
•Re: Nested #! interpreters
by merlyn (Sage) on Feb 21, 2004 at 22:03 UTC | |
|
Re: Nested #! interpreters
by ambrus (Abbot) on Feb 21, 2004 at 20:42 UTC | |
|
Re: Nested #! interpreters
by flyingmoose (Priest) on Feb 21, 2004 at 21:49 UTC |