Linux – Differences between linux and Solaris /usr/bin/env

envlinuxperlsolaris

I've a simple script:

#!/usr/bin/env perl -w
print "Hello World\n"

Make this executable, run on Linux, and I get:

/usr/bin/env: perl -w: No such file or directory

(without the -w, this works OK)

Running the same script on a Solaris 8 machine produces the correct output.

Any suggestions as to why this is ?

Best Answer

It's not env; it's the kernel's #! handler. Everything after the first word (/usr/bin/env) is passed as a single argument string. Safest/most portable is to not put anything after the perl there.

Related Topic