【发布时间】:2020-06-16 10:27:45
【问题描述】:
我正在尝试运行具有 sudo 访问权限的 shell 脚本,该脚本在 Mac 上使用 Node.js 执行 python 脚本。这是一个很大的帮助How to run shell script file using nodejs?,但我被卡住了:
Shell 脚本:
#!/bin/sh
sudo -S python [pathToPythonScript]/someScripts.py
Node.js 代码:
const shell = require('shelljs');
shell.exec("./[pathToShellScript]");
当我在 WebStorm 中运行它时,系统会提示我输入密码。我这样做了,但什么也没发生;脚本未执行。有人可以帮我解决这个问题吗?
【问题讨论】: