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
31
votes
4 answers

How to execute a java script with jshell?

Given that Java 9 is upon us and we can finally have a java REPL with jshell I was hoping there was a way to add a shebang to a script and have jshell interpret it. I tried creating test.jsh: #!/usr/bin/env jshell -s System.out.println("Hello…
steinybot
  • 5,491
  • 6
  • 37
  • 55
29
votes
1 answer

Bash shebang option -l

I use a script, test.sh, written by someone else, the begins with a bash shebang: #!/bin/bash -l ... echo TEST: $TEST From what I could see, this has an effect on variables used inside the script: if I run TEST=hey ./test.sh, I can see TEST: hop,…
Emmanuel
  • 13,935
  • 12
  • 50
  • 72
28
votes
1 answer

Make Node.js support the shebang (#!) for JavaScript files

Some scripting languages (such as Python or Bash) use # for comments. #!/usr/bin/env python print 'hello, world' I can run the script: python script.py Or ./script.py Is it possible to make JavaScript support shebang?
kev
  • 155,172
  • 47
  • 273
  • 272
27
votes
3 answers

Shebang and Groovy

Is it possible to declare at the start of a file that it should be executed as a Groovy script? Examples for other scripting languages: #!/bin/sh #!/usr/bin/python #!/usr/bin/perl
Nulldevice
  • 3,926
  • 3
  • 31
  • 37
27
votes
1 answer

How to make python scripts executable on Windows?

Possible Duplicate: Set up Python on Windows to not type python in cmd When I use python on Linux, or even Mac OS from command line, I take advantage of the shebang and run some of my scripts directly, like so: ./myScript.py. I do need to give…
Hamish Grubijan
  • 10,562
  • 23
  • 99
  • 147
26
votes
2 answers

Makefile as an executable script with shebang?

Is it possible to create an executable script that would be interpreted by make? I tried this: #!/usr/bin/env make --makefile=/dev/stdin main: @echo Hello! but it does not work - hangs until press Ctrl-c.
Aleksandr Levchuk
  • 3,751
  • 4
  • 35
  • 47
24
votes
3 answers

Java 11: Executing Source File via Shebang is not working

I wanted to check out some new features of java 11 which was released two days ago. JEP 330 states that I could launch a Java-Source-Code-Program without compiling. It should also support the usage of Shebang-Files. Hence I have written this small…
mam10eks
  • 986
  • 7
  • 16
24
votes
4 answers

Shell script shebang for unknown path

Is it possible to specify a shebang line without knowing the path of the program you want to do the executing? maybe don't specify the path #!node or specify several options #!/usr/local/bin/node #!/usr/bin/node Extra points for cross platform…
Billy Moon
  • 57,113
  • 24
  • 136
  • 237
22
votes
8 answers

Is there a standard way to make sure a python script will be interpreted by python2 and not python3?

Is there a standard way to make sure a python script will be interpreted by python2 and not python3? On my distro, I can use #!/usr/bin/env python2 as the shebang, but it seems not all distros ship "python2". I could explicitly call a specific…
static_rtti
  • 53,760
  • 47
  • 136
  • 192
22
votes
1 answer

Why can't the import command be found?

I am using the input function from fileinput module to accept script via pipes or input file Here is the minimum script: finput.py import fileinput with fileinput.input() as f: for line in f: print(line) After making this script…
styvane
  • 59,869
  • 19
  • 150
  • 156
21
votes
3 answers

How to Make my R script executable?

I am aware this is at high risk of being a duplicate, but in none of the other questions here I have found an answer to my problem. Below is a summary of what I have already tried. I have an R script file file.r: #!/usr/bin/env Rscript print("Hello…
k88074
  • 2,042
  • 5
  • 29
  • 43
21
votes
3 answers

Require ruby file without .rb extension?

I have a ruby file that does not have a .rb extension, and is instead identified as ruby code with a shebang at the beginning of the file: #!/usr/bin/env ruby. I want to require the code in this file in another ruby file, but it seems to be having…
Kvass
  • 8,294
  • 12
  • 65
  • 108
20
votes
5 answers

How to check syntax of ruby script that has script/runner as a shebang?

I have problems to check syntax of ruby scripts that has rails script/runner on its shebang. Here are two example scripts and how they responses to ruby syntax checking: Script hello_world_runner.rb: #!/usr/bin/env script/runner p "Hello…
Joni
  • 3,327
  • 3
  • 25
  • 22
20
votes
5 answers

How to execute Rust code directly on Unix systems? (using the shebang)

From reading this thread, it looks like its possible to use the shebang to run Rust *. #!/usr/bin/env rustc fn main() { println!("Hello World!"); } Making this executable and running does compile, but not run the code. chmod +x…
ideasman42
  • 42,413
  • 44
  • 197
  • 320
20
votes
8 answers

What does #!/usr/bin/... at the start of a file mean?

I can do something like this in Haskell: #!/usr/bin/runghc main=putStrLn "Hello World" Then I can run it with ./hello.hs My question is, why is the first line ignored? Comments in haskell start with -- but the first line still seems to be ignored.…
Lucky
  • 4,787
  • 9
  • 40
  • 50
1 2
3
32 33