Joyent

 
Translations of this page:

Shebang line

The so-called shebang line is the first-most line in an executable script, which tells the operating system what kind of interpreter it should use to execute the script with. For instance, for a Perl script, the shebang like looks like this:

#!/usr/local/bin/perl

It is basically the full path to the binary, preceded with #!.

It is critical that scripts contain a correct shebang line - if they don't, the only way to execute them is to explicitly call the interpreter and pass the script file as an argument, e.g.

perl /users/home/myaccount/cgi-bin/somescript.pl

This is particularly important when using Cron jobs, as Cron executes in a restricted environment, which doesn't include paths inside /usr/local, where pretty much all binaries live in on our servers. Some (namely Ruby) scripts come with a 'smart' shebang line that uses the 'env' binary to figure out where the interpreter is, e.g.

#!/usr/bin/env ruby

Not even that will work in a Cron job though, so you should fix such script to use full path only.

 
shared/kb/shebang.txt · Last modified: 2007/08/03 23:12 by filip
 
Recent changes RSS feed Creative Commons License Driven by DokuWiki