Appropriate hashbang for Node.js scripts

If your script is intended for use by Node developers, you should absolutely just use #!/usr/bin/env node and not bother trying for compatibility with people who only have Node installed as nodejs. Rationale: It’s what the cool kids are doing, and if you don’t do it too, you’re not cool. Major node projects like jshint, … Read more

What exactly does “/usr/bin/env node” do at the beginning of node files?

#!/usr/bin/env node is an instance of a shebang line: the very first line in an executable plain-text file on Unix-like platforms that tells the system what interpreter to pass that file to for execution, via the command line following the magic #! prefix (called shebang). Note: Windows does not support shebang lines, so they’re effectively … Read more

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

What is the difference between “#!/usr/bin/env bash” and “#!/usr/bin/bash”?

Running a command through /usr/bin/env has the benefit of looking for whatever the default version of the program is in your current environment. This way, you don’t have to look for it in a specific place on the system, as those paths may be in different locations on different systems. As long as it’s in … Read more

Should I put #! (shebang) in Python scripts, and what form should it take?

The shebang line in any script determines the script’s ability to be executed like a standalone executable without typing python beforehand in the terminal or when double clicking it in a file manager (when configured properly). It isn’t necessary but generally put there so when someone sees the file opened in an editor, they immediately … Read more

Why do people write #!/usr/bin/env python on the first line of a Python script?

If you have several versions of Python installed, /usr/bin/env will ensure the interpreter used is the first one on your environment’s $PATH. The alternative would be to hardcode something like #!/usr/bin/python; that’s ok, but less flexible. In Unix, an executable file that’s meant to be interpreted can indicate what interpreter to use by having a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)