强制 node.js 使用 bin/bash 而不是 sh

编程入门 行业动态 更新时间:2024-10-12 14:18:40
本文介绍了强制 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

本文发布于:2023-10-09 05:35:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1474851.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:而不是   js   node   bin   sh

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!