node.js - 使用 node.js 运行 shell 命令
问题描述
我有这个代码:
convert -limit memory 2MB \( /var/www/html/sistema/publico/uploads/3_5_foto_formatada.png /var/www/html/sistema/publico/uploads/3_8_foto_formatada.png /var/www/html/sistema/publico/uploads/3_2_foto_formatada.png +append \) \
\( /var/www/html/sistema/publico/uploads/3_7_foto_formatada.png /var/www/html/sistema/publico/uploads/3_4_foto_formatada.png /var/www/html/sistema/publico/uploads/3_6_foto_formatada.png +append \) \
\( /var/www/html/sistema/publico/uploads/3_6_foto_formatada.png /var/www/html/sistema/publico/uploads/3_6_foto_formatada.png /var/www/html/sistema/publico/uploads/3_6_foto_formatada.png +append \) \
-background none -append /var/www/html/sistema/publico/uploads/3_unidas.png
当我在腻子上运行它时,它工作得很好。
但是当我尝试在 node.js 上运行它时,它给了我一些错误,比如这段代码不正确。
喜欢:
/bin/sh: 2: (: 未找到 /bin/sh: 3: (: 未找到 /bin/sh: 4: -background: 未找到
我包含了这个库: const {execSync} = require('child_process');
我以这种方式运行:
let output = execSync(varWithCommand);
提前致谢!
解决方案
推荐阅读
- java - 有基于 gradle 标志的注释处理器忽略文件
- java - 当我将 WHERE 子句放入 objectDB 时,UPDATE 命令出现问题
- android - 正在调用 OnBackPressedCallback,但应用程序不会返回
- machine-learning - 如何将网络摄像头图像转换为 RGB 深度
- ios - swift / CoreData - 为数据模型创建“虚拟”NSManagedObjecID(无需托管对象即可测试事物)
- angular - 如何使用 Web SDK 执行基于 Fire 的电话身份验证?
- ios - 删除 UITextField 中的重复条目
- c# - 无法使用 Postman 从数据库获取数据,但 POST 工作正常
- angular - 焦点上的垫子输入不起作用Angular7
- python - 在python中如何替换稀疏csr_matrix中的nan