I use linux. In one script ("/home/weigand/tmp.pl"), I do this:
#!/bin/env /home/weigand/perl_wrapper.pl print "Hello world from perl.\n";
My "/home/weigand/perl_wrapper.pl" script is just a perl script:
#!/usr/bin/perl print "In perl wrapper.\n"; ...
Question: While in the perl_wrapper.pl script, is there any way to get the name of the file "/home/weigand/tmp.pl" in this case?
The reason why I want to know is that I want the perl_wrapper.pl script to execute "perl /home/weigand/tmp.pl". It's a wrapper script for perl, so its job is to determine which perl binary to use and then execute the original script (/home/weigand/tmp.pl in this case) with the right perl binary.
Yes I know there are other ways of writing wrapper scripts. I'd like to stick with this particular question rather than solicit alternatives.
Yes, I know you can make symbolic links at /usr/local/bin to point to different perl binaries for different architectures. That's not what I want.
Any ideas?
I guess I could find the process ID of the parent (which is the /bin/env process I suppose). And then look at its open file list or something. Not sure exactly how to do that or if that's really my best shot.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |