I'm trying to execute a basic bash script from node using the exec()
function. The bash script is as follows:
#!/bin/bash
ffmpeg -f concat -i <(for f in $1/*.mov ; do echo "file '$f'"; done) -c copy $1/output.mov
The script works fine running it from the command line but when running from within node I get a syntax error: line 2: syntax error near unexpected token
('`
It appears when running this command node it attempting to use sh
instead of bash
. Can anyone verify this is true and give a possible workaround or solution? Thanks ahead of time!
Provided you're on a recent version of Node, you can add the following as option for exec:
{shell: "/bin/bash"}
See: https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback
Try child_process.execFile or just explicitly run ['/bin/bash', '/path/to/your/script.sh', arg1, arg2...]
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With