Daniel Macks on Fri, 14 Apr 2000 17:48:24 -0400 (EDT) |
John Kirk said: : : I've hit a snag that makes me think there's something I've missed : or something I don't know. The initial issue was that I wanted to : use shebang notation in one file to have that file, when executed, : cause another perl script (itself using shebang notation referring : to perl) to read the first file and process it. When my initial : tries didn't work [...] I just messed with strace (this is all under Linux from tcsh...I'd assume other Unicycles would be similar and other OSs likely different). It looks like when confronted with an execution request for a script, execve() is called with the filename and the list of command-line arguments (including the filename). +----- man execve |EXECVE(2) Linux Programmer's Manual EXECVE(2) | |NAME | execve - execute program | |DESCRIPTION | 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 path- | name for an executable which is not itself a script, which | will be invoked as interpreter [arg] filename. +----- That last point looks like the cause of the problem you encountered. So shebang's gotta point to a compiled program (so a Perl program is out, but the Perl interpretter is okay). Since perl can be given a command-line filename of a script to run (which is what execve does when you call a perl script directly), why not use a shebang line that includes the perl script filename? +----- myscript |#!/home/dmacks/bin/perl /home/dmacks/bin/myinterpretter +----- +----- myinterpretter |print "I am $0, called with @ARGV\n"; +----- myscript bananas --> I am /home/dmacks/myinterpretter, called with myscript bananas So myinterpretter is a perl program that gets called with the name of the script file that the user called, followed by any arguments passed to that script. Not sure how robust this is (in particular, I wasn't able to to passing arguments to myinterpretter in the shebang line of myscript). dan -- Daniel Macks dmacks@a.chem.upenn.edu dmacks@netspace.org http://www.netspace.org/~dmacks **Majordomo list services provided by PANIX <URL:http://www.panix.com>** **To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**
|
|