What does the line “#!/bin/sh” mean in a UNIX shell script?

It’s called a shebang, and tells the parent shell which interpreter should be used to execute the script. #!/bin/sh <——— bourne shell compatible script #!/usr/bin/perl <– perl script #!/usr/bin/php <— php script #!/bin/false <—— do-nothing script, because false returns immediately anyways. Most scripting languages tend to interpret a line starting with # as comment and … Read more

Should I use a Shebang with Bash scripts?

On UNIX-like systems, you should always start scripts with a shebang line. The system call execve (which is responsible for starting programs) relies on an executable having either an executable header or a shebang line. From FreeBSD’s execve manual page: The execve() system call transforms the calling process into a new process. The new process … Read more

How do I ignore the Perl shebang on Windows with Apache 2?

I use #!/usr/bin/perl in my scripts and configure Apache on Windows to ignore the shebang line. Add ScriptInterpreterSource Registry-Strict to your httpd.conf and set up the Windows Registry key as explained in the Apache docs. Here is what I get when I export the key: Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\.pl\Shell\ExecCGI\Command] @=”c:\\opt\\perl\\bin\\perl.exe” I have been … Read more