NodeJS 执行提示键盘输入的 bash 脚本
NodeJS Execute a bash script that prompts for keyboard input
我正在尝试从 nodejs 执行外部 bash 脚本。
从终端执行脚本时,提示输入,例如密码。
从 nodejs 执行时,我无法让它暂停以读取输入。
在网上找不到任何关于此的好信息。
这不可能吗?
var shelljs = require( 'shelljs' )
var returns = shelljs.exec("passwd", {shell: '/bin/bash'}, {stdio:'inherit'});
passwd: conversation failure
shelljs.exec("exec </dev/tty\n passwd", ... )
seems to work. found by accident.
不确定这是否是最好的方法。
我觉得不是很扎实。
我正在尝试从 nodejs 执行外部 bash 脚本。
从终端执行脚本时,提示输入,例如密码。
从 nodejs 执行时,我无法让它暂停以读取输入。
在网上找不到任何关于此的好信息。
这不可能吗?
var shelljs = require( 'shelljs' )
var returns = shelljs.exec("passwd", {shell: '/bin/bash'}, {stdio:'inherit'});
passwd: conversation failure
shelljs.exec("exec </dev/tty\n passwd", ... )
seems to work. found by accident.
不确定这是否是最好的方法。
我觉得不是很扎实。