I'm calling runShellScript() as below. Can I make it return the bash output from echo? as it stands it doesn't appear to do this
let shellScriptWrapper = {
script: `echo "fff"`,
launchPath: '/bin/bash',
parameters: '-c',
environmentVariables: ''
};
runShellScript( shellScriptWrapper )
It should be working but runShellScript returns a promise. Here is an example from the docs:
async function runSomeShellScriptScript() {
// put the shell script into a string (single backticks are great for multiline strings)
let shellScript = `echo "hello world"`;
let shellScriptWrapper = {
script: shellScript, // mandatory
launchPath: '/bin/bash', //optional - default is /bin/bash
parameters: '-c', // optional - default is -c
environmentVariables: '' //optional e.g. VAR1=/test/;VAR2=/test2/;
};
// this will execute the Shell Script and store the result in the result variable.
let result = await runShellScript(shellScriptWrapper);
//do whatever you want with the result
document.getElementById("testButton").value=result;
console.log('result', result);
}