强制 node.js 使用 bin/bash 而不是 sh [英] Force node.js to use bin/bash instead of sh

查看:49
本文介绍了强制 node.js 使用 bin/bash 而不是 sh的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 exec() 函数从节点执行一个基本的 bash 脚本.bash脚本如下:

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

脚本在命令行中运行良好,但在节点内运行时出现语法错误:line 2: syntax error near unexpected token('`

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('`

它在运行这个命令节点时出现,它试图使用 sh 而不是 bash.任何人都可以验证这是真的并提供可能的解决方法或解决方案吗?提前致谢!

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!

推荐答案

尝试 child_process.execFile 或直接运行 ['/bin/bash', '/path/to/your/script.sh', arg1, arg2...].

Try child_process.execFile or just explicitly run ['/bin/bash', '/path/to/your/script.sh', arg1, arg2...].

这篇关于强制 node.js 使用 bin/bash 而不是 sh的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆