April 30th, 2007
HOWTO make portable script shebang with /usr/bin/env
Not all Unix/Linux systems are created equal. While on one server you might find your perl binary in /usr/bin/perl another server might have it in /usr/local/bin/perl.
It is not a huge deal to change this around manually, but there is an option you can use that will give you working script that will work anywhere… Using the /usr/bin/env command.
Lets say you have a cgi script that does
#!/usr/bin/perl
modify that to
#!/usr/bin/env perl
And that’s it! Your script should work on any system that has perl installed. This can be used for bash, php, etc anything really. Just replace perl with what you want to use, ie: /usr/bin/env bash , /usr/bin/env php. Upload your file and it is ready to run anywhere.
Hope it helps, happy serving ![]()
Powered by Gregarious (42)
Share This now!
Poor man’s 3d button with pure CSS