exec
Run a shell command and return combined output.
js
exec(command, asRoot = false)Arguments
| Argument | Type | Meaning |
|---|---|---|
command | string | Shell command. |
asRoot | boolean | Default false; true requests root. |
Returns
Combined output string. Service failures and the 30-second timeout throw.
Example
js
console.log(exec("id -u"));Notes
A nonzero shell exit code is not automatically a JavaScript exception. Use execResult for reliable status checks.