【发布时间】:2019-02-01 18:14:16
【问题描述】:
我的文件结构如下:
--backend/
---script (unix executable)
--src/
---script_launcher.js
---main.js
--all other necessary files
script 是一个 unix 可执行文件,我使用 pyinstaller 从 python 脚本构建。 script_launcher.js 应该启动 unix 可执行文件script,通过标准输入将参数传递给它并监听:任何标准输出/任何错误/脚本完成执行时。在 unix 可执行文件之前,我有一个 .py 文件,我将使用来自 script_launcher.js 的 python-shell npm module 调用它。我知道我应该使用child-processes,但是:
-
spawn似乎只适用于 python 脚本而不适用于 unix 可执行文件(不允许我执行script)
const spawn = require("child_process").spawn;
const pythonProcess = spawn("path/to/script", arg1, arg2);
-
exec或execFile似乎不允许我以python-shell让我阅读信息的方式阅读我上面描述的信息。
调用 unix 可执行文件的最佳方法是什么?另外,在调用它们时,我应该使用路径作为/path/to/script 还是/path/to/script.exec?我不太明白script 是否有文件扩展名。
【问题讨论】:
标签: python node.js electron node-modules