Skip to main content
14 events
when toggle format what by license comment
Mar 4, 2024 at 11:34 comment added Vilinkameni ... the script must have the executable bit set and invoked as ./my_shell_script.sh. As @Olivier Dulac noted in the comment, this is valid only when the script is in the current directory. Otherwise something like /path/to/the/script/my_shell_script.sh or ../../other/dir/my_shell_script.sh must be used. And if the script is in the directory listed in the PATH, then just my_shell_script.sh will suffice.
Nov 10, 2021 at 21:14 comment added The Quark "Note that if you invoke a script by specifying the interpreter on the command line, as is done in both cases given in the question, exec() will execute the interpreter specified on the command line, it won't even look at the script." This explains why running ./myscript.sh results in a process named "myscript.sh" whereas running bash myscript.sh (or having #! /usr/bin/env bash in the shebang line) results in a "bash" process. Thanks!
May 13, 2021 at 21:25 comment added FKEinternet Node.js is a Javascript program, not a Java program, so any similarities between the behavior of Node.js and the Java API are purely coincidental.
Dec 12, 2016 at 3:02 comment added Thomas Nyman @AlexanderMills I would imagine child_process.{exec(),execFile(),spawn()} all would be implemented using the C exec() (through process).
Dec 11, 2016 at 19:51 comment added Alexander Mills Huh, yeah I am indeede familiar with the Java API you just mentioned, I wonder if there is a way to invoke the lower level exec() call from Node.js somehow
Dec 11, 2016 at 16:02 comment added Thomas Nyman @AlexanderMills The exec() referred to in this answer is a system call, the command exec is a shell builtin, which is why you cannot invoke an exec program from Node.js or Java. However, any shell command invoked by e.g. Runtime.exec() in Java is eventually processed by the exec() system call.
Dec 9, 2016 at 20:26 comment added Alexander Mills thanks Thomas for this answer. Pretend we launch the script as a child process from Node.js or Java or whatever. Can we launch an "exec" process, and then exec will run the shell script? I ask beause I am looking for answers to this question: stackoverflow.com/questions/41067872/…
Nov 8, 2016 at 14:29 history edited Jeff Schaller CC BY-SA 3.0
deleted 5 characters in body
Aug 21, 2013 at 11:07 vote accept jrara
Aug 21, 2013 at 11:06 history edited Lesmana CC BY-SA 3.0
clarify
Aug 21, 2013 at 10:30 history edited Thomas Nyman CC BY-SA 3.0
fix grammar, remove unnecessary remark about $PATH, improve example
Aug 21, 2013 at 10:25 history edited Thomas Nyman CC BY-SA 3.0
fix grammar, remove unnecessary remark about $PATH
Aug 21, 2013 at 10:15 history edited Thomas Nyman CC BY-SA 3.0
add explanation of script
Aug 21, 2013 at 10:10 history answered Thomas Nyman CC BY-SA 3.0