Shebang
From A2Wiki
A shebang is the first line of a script on *nix systems that tells the system what interpreter to invoke to run the rest of the script. This (along with the addition of execution permission to the file) allows the script to be run as a command itself so that the interpreter does not have to be explicitly invoked from the command line -- this is especially important for CGI scripts. The format of a shebang line is usually
#!/path/to/interpreter [interpreter flags/options]
for example:
#!/usr/bin/perl -w
Please note that in many scripting languages '#' indicates the beginning of a comment line (a line that is ignored by the interpreter), however the shebang line is a special exception to this rule.
A2 Hosting Shebangs:
- Perl
#!/usr/bin/perl
- Python
#!/usr/local/bin/python
- Ruby
#!/usr/local/bin/ruby
- PHP
#!/usr/local/bin/php
/usr/bin/env
One way to get around the different locations for the interpreters is to have your script ask the env for the location of the interpreter right in the shebang line. For example:
#!/usr/bin/env ruby
This example would locate the ruby interpreter whether it was located at /usr/bin/ruby or /usr/local/bin/ruby.
