Questions tagged [interpreter]

19 questions
21
votes
6 answers

Choose interpreter after script start e.g. if/else inside hashbang

Is there any way to dynamically choose the interpreter that's executing a script? I have a script that I'm running on two different systems, and the interpreter I want to use is located in different locations on the two systems. What I end up having…
dkv
  • 459
  • 1
  • 5
  • 10
7
votes
3 answers

Is parsing scripts at script-runtime ubiquitous to shells or present in other interpreters and how does that work?

I had always thought that shells parse whole scripts, constructing an AST, and then execute that AST from memory. However, I just read a comment by Stéphane Chazelas, and tested executing this script, edit-while-executing.sh: #!/bin/bash echo…
JoL
  • 4,520
  • 15
  • 35
6
votes
6 answers

Run program at lower CPU speed?

It would be very useful for me to run specific programs in a Linux environment with a fixed (lower) CPU clock speed (say, runat 400mhz ./my-program --argument-of="my program" for getting that clock speed). I need it to generate delays between each…
mgarciaisaia
  • 252
  • 4
  • 9
6
votes
1 answer

Perl and Python wrongly interpreted via shebang on Linux

All my Python and Perl scripts are simply NOT iterpreted via shebang. Never. But they work as expected when I explicitly call the binary. I double checked my Perl and Python installations, it is just too strange: they shebang-way execution works…
appzer0
  • 63
  • 5
4
votes
2 answers

Specifying a generic interpreter for a program like expect?

I am writing expect script which can be used on mulple operating systems but the problem is i can't use #!/usr/bin/expect evreywhere so instead i tried to do #!`which expect` at the top but it failed [sesiv@itseelm-lx4151 ~]$ ./sendcommand -bash:…
munish
  • 7,825
  • 24
  • 71
  • 97
4
votes
3 answers

Who runs the interpreter for files that are execute-only?

If the current user only has execute (--x) permissions on a file, under which user does the interpreter (specified by #!/path/to/interpreter at the beginning of the file) run? It couldn't be the current user, because he doesn't have permission to…
ATLief
  • 290
  • 1
  • 10
3
votes
2 answers

xslt shbang: Using xslt from the command line

I have (foolishly?) written a couple of moderately general-purpose xslt scripts. I'd quite like to turn these into executables that read an xml document from standard in or similar. The way you do this with other languages is to use a shbang. Is…
Att Righ
  • 1,176
  • 11
  • 29
2
votes
0 answers

How to trace script execution events

My goal: To receive events from the kernel when a file/script is opened for execution with the absolute path of the file (or maybe the working directory, to resolve the absolute path of the file). I don't want to get events on every file opened. I…
faraopera
  • 21
  • 2
2
votes
1 answer

Why " >/dev/console" for remote beep (echo-command)

I've learned that this command: echo -e "\a" triggers a beep on the local system, whereas this command: echo -e "\a" >/dev/console triggers a beep on a remote system. Why is this? What is the >/dev/console part doing? Why is it that executing echo…
1
vote
3 answers

Is shebang always the same as the interpreter's installation directory?

Must the shebang header always match the interpreter's installation directory? If so, then why do both #!/usr/bin/python and #!/usr/local/bin/python work for me?
avimehenwal
  • 169
  • 2
  • 9
1
vote
1 answer

Building "cross linux system" programs, with different libc/musl interpreter

My goal is simple: I would like to create a program that bootstraps the nix package manager on any architecture, as a non-root user, with as few depends as possible. For now, what I did is the following: I download on the host a minimalist alpine…
tobiasBora
  • 3,376
  • 2
  • 23
  • 34
0
votes
0 answers

VS Code Won't Recognize R Installation

I installed R via the commands at this website. Running R in terminal works properly; running which R returns /usr/bin/R. VS code cannot find R despite the path for rterm and rpath being given explicitly in the settings (near the bottom): { …
0
votes
2 answers

can something besides the shebang set the interpreter?

I'm running a script (in tmuxinator) that tries to source another script (rvm). rvm explicitly does not allow sourcing from sh. I didn't think that would be a problem, because the shebang in the tmuxinator script is #!/bin/bash but when I insert…
bgates
  • 101
  • 2
0
votes
1 answer

Does the shell script interpreter optimize if else chains?

As far as I understand, an interpreter runs code line by line; but I find probable that my reasoning is incorrect. If in this example case the first if line returns true, will the program know to skip to fi after echo "APPROVED" (and will it know…
0
votes
2 answers

Why two or more read commands cannot be executed in one go (without some separation syntax)?

I tried to copy-paste the following two commands into the terminal directly and to then execute them: read -s x read -s y Current output is empty prompt but desired output is the first read execution and then the second read execution. I can…
George
  • 9
  • 2
1
2