Allocate terminal with child

I'm using child_process to run a script that ultimately calls

ssh -t server "sudo command"

I get back:

Pseudo-terminal will not be allocated because stdin is not a terminal.
sudo: sorry, you must have a tty to run sudo

Is there any way to make the process' stdin a terminal? It's being run like so;

var proc = child_process.spawn(pathToCommand, ["args"]);
proc.stdout.on("data", function (data) {                          
    socket.emit("running", "" + data);                                      
});                                                                         

proc.stderr.on("data", function (err) {                           
    socket.emit("error", "" + err);                                         
});                                                                         

proc.on("close", function (code) {                                
    socket.emit("finished", "" + code);                                     
});

I would like to avoid forcing terminal allocation for ssh via -tt . Instead I would just like to allocate a terminal for the process. Is this doable?


ssh2模块允许在使用shell()或exec()时设置远程端使用的pty。

链接地址: http://www.djcxy.com/p/97134.html

上一篇: SSH在没有连接到shell脚本中的服务器的情况下退出

下一篇: 与孩子分配终端