我的 bash 脚本如下所示:
read -p "Do you wish to continue?" yn
# further actions ...
我只想使用 nodejs / child_process 与这个脚本进行交互。如何检测到它正在等待用户输入?
var spawn = require('child_process').spawn;
var proc = spawn('./script.sh');
proc.stdout.on("data", function(data) {
console.log("Data from bash");
}
proc.stdin.on("data", function(data) {
console.log("Data from bash"); // doesn't work :/
}
谢谢!