Я пытаюсь запустить команды в Windows через дочерние процессы NodeJS:
var terminal = require('child_process').spawn('cmd');
terminal.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
terminal.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
terminal.on('exit', function (code) {
console.log('child process exited with code ' + code);
});
setTimeout(function() {
terminal.stdin.write('echo %PATH%');
}, 2000);
Когда он вызывает ti.stdin.write
, он записывает его в дескриптор stdin
, но как мне активировать cmd
для реагирования на данный момент? Как отправить сигнал клавиши "enter", который вы делаете, когда вы действительно вводите командную строку? В настоящее время я не получаю ответа от cmd
.