Questions tagged [shebang]

The #! marker at the beginning of scripts is called a shebang.

The #! marker at the beginning of scripts is called a shebang.

See

486 questions
18
votes
2 answers

Generating a bash script with echo, problem with shebang line

I want to explain to some friends how to add multikey support to their linux systems at bootup but first I need them to make a bash script. I want to make a simple command for them to copy and paste and I'm testing out this command I made but it…
Isaiah
  • 1,995
  • 2
  • 18
  • 29
18
votes
3 answers

How can an ES6 module be run as a script in Node?

How can an ES6 module be run as a script in Node? When I try this shebang I get an error: #!/usr/bin/env node --experimental-modules /usr/bin/env: ‘node --experimental-modules’: No such file or directory If I use this shebang it has syntax errors…
curiousdannii
  • 1,658
  • 1
  • 25
  • 40
18
votes
4 answers

How do I activate a conda env in a subshell?

I've written a python program. And if I have a shebang like this one: #!/usr/bin/python and I make the file executable with: $ chmod 755 program.py I can run the program like so: $ ./program.py Here is the issue. I use the conda virtual…
meh
  • 2,591
  • 4
  • 20
  • 33
18
votes
2 answers

Why does this snippet with a shebang #!/bin/sh and exec python inside 4 single quotes work?

I'm trying to understand one of the answers to this question: Cannot pass an argument to python with "#!/usr/bin/env python" #!/bin/sh ''''exec python -u -- "$0" ${1+"$@"} # ''' This works well, but I do not understand why it works with four ticks…
John Schmitt
  • 1,148
  • 17
  • 39
17
votes
2 answers

Conditional shebang line for different versions of Python

I have a problem when trying to run a python script on two different computers. On each computer I would like to run the script using python version 2.7.3 however the problem I am having is that the two computers name python 2.7.3 in different…
martega
  • 2,103
  • 2
  • 21
  • 33
15
votes
4 answers

Are there any javascript libraries for working with hashbang/shebang (#!) urls?

With all the negative press over Twitter and Gawker's use of hashbang urls I'm having a very hard time finding any examples/libraries for how to actually use them. I'd like to use hashbang urls in a javascript carousel on our website so we can link…
Twipped
  • 1,149
  • 12
  • 24
15
votes
6 answers

How do I find where Python is located on Unix?

I'm working on a new server for a new workplace, and I'm trying to reuse a CGI script I wrote in Python earlier this year. My CGI script starts off with #!/local/usr/bin/python But when I run this on the new server, it complains that there's no…
Adam
  • 482
  • 1
  • 4
  • 12
15
votes
5 answers

shebang env preferred python version

I have some python-2.x scripts which I copy between different systems, Debian and Arch linux. Debian install python as '/usr/bin/python' while Arch installs it as '/usr/bin/python2'. A problem is that on Arch linux '/usr/bin/python' also exists…
jaap
  • 5,661
  • 2
  • 20
  • 25
14
votes
4 answers

using #!/usr/bin/env python3 shebang with Windows

I'm trying to run a Python script from the command line as a command on Windows -- so no usage of "Python" or ".py". If my script is named "testing.py", I am attempting to make this name into a command and call "testing" from the command line. Going…
MasayoMusic
  • 594
  • 1
  • 6
  • 24
14
votes
1 answer

Shebangs in conda managed environments

I am trying to write a program in Hy and run it per the instructions on the Quickstart page in the documentation. So I installed Hy using pip from the GitHub repo per the docs, then added executable permissions to the file with chmod +x myfile.hy.…
Hugo
  • 546
  • 5
  • 12
14
votes
2 answers

Effects of comment (#) lines before and/or after the comment-like #!/bin/sh line

Example one #!/bin/sh # purpose: print out current directory name and contents pwd ls Example two # purpose: print out current directory name and contents #!/bin/sh pwd ls What is the difference – if I make the first line a comment(#), with…
Manikanta
  • 141
  • 1
  • 4
13
votes
6 answers

Python source header comment

What is the line #!/usr/bin/env python in the first line of a python script used for?
Alex
  • 43,191
  • 44
  • 96
  • 127
13
votes
5 answers

Python deployment and /usr/bin/env portability

At the beginning of all my executable Python scripts I put the shebang line: #!/usr/bin/env python I'm running these scripts on a system where env python yields a Python 2.2 environment. My scripts quickly fail because I have a manual check for a…
cdleary
  • 69,512
  • 53
  • 163
  • 191
13
votes
2 answers

Shebang for psql

I'm trying to write PostgreSQL script(s) but having a problem with shebang line #! /usr/bin/psql [ psql_args_here ] -f select now(); This gives me error as if I just entered psql without any arguments in command line. How do I do it right?
Mark Gurevich
  • 228
  • 2
  • 9
13
votes
2 answers

Relative shebang: How to write an executable script running portable interpreter which comes with it

Let's say we have a program/package which comes along with its own interpreter and a set of scripts which should invoke it on their execution (using shebang). And let's say we want to keep it portable, so it remains functioning even if simply copied…
Anton
  • 6,349
  • 1
  • 25
  • 53