in reply to perl script used as sh-bang
I'd have thought you could write a simple C wrapper that execs perl with the interpreter and the 'simple language' script as its arguments, much as we recommend for suid perl scripts.
All the script needs to do is create a copy of its arguments with the interpreter script inserted at the right place; I'm a bit rusty on this, but I think it should look something like:
#include <unistd.h> #include <stdlib.h> char* perl = "/usr/bin/perl"; char* target = "/home/gabor/bin/sli.pl"; int main(int argc, char* argv[]) { char** argv2 = (char**)malloc(sizeof(char*) * (argc + 2)); int i; argv2[0] = argv[0]; argv2[1] = target; for (i = 1; i < argc; ++i) { argv2[i + 1] = argv[i]; } argv2[argc + 1] = (char*)NULL; return execv(perl, argv2); }
Hugo
|
|---|