Hey, i have a bash alias on my ubuntu server
myalias="some unix command here"
When running node:
child_process.exec('myalias', {shell: '/bin/bash'},
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});
Result with the following error:
_exec error: Error: Command failed: /bin/bash -c myalias_
How can i workaround to run alias or bash function in order to shortcut a long command line.
Thanks in advance!
I believe bash only expands aliases when the shell is interactive by default.
any workaround? (except of saving the long command in a .sh file)
@unbalanced It's probably more reliable to actually just call the command you want. If it's too large for that it's probably best to use a shell file anyways.
I wanted it to be a little more modular (and less code/command duplication)
Thanks for the response guys.