javascript - Using PsExec with spawning a child process results in truncated stdout -
javascript - Using PsExec with spawning a child process results in truncated stdout -
my goal able execute command on remote machine , total stdout response command run. getting truncated result. when run same command through command prompt, total output command run. here code:
var process = spawn('psexec.exe', ['\\\\servername', 'ipconfig']); var doonce = true; process.stdout.on('data', function (data) { log.info('stdout: ' + data.tostring()); if(doonce){ doonce = false; process.stdin.write('ipconfig');} }); process.stderr.on('data', function (data) { log.info('stderr: ' + data.tostring()); }); process.on('exit', function (code) { log.info('child process exited code ' + code); });
when executed next console output. can tell, of ipconfig has been truncated. if command such netstat, of results before truncating occurs, don't believe has buffer. out of ideas @ point.
info: stderr: psexec v2.11 - execute processes remotely copyright (c) 2001-2014 mark russinovich sysinternals - www.sysinternals.com info: stdout: windows ip configuration ipconfig exited on servername error code 0. info: kid process exited code 0
try using { stdio: 'inherit' } option
var spawn = require('child_process').spawn, appname = spawn('psexec.exe', ['-accepteula', '\\\\remotepcname', '-u', 'domain\\username', '-p', 'supersecretpassword', 'ipconfig'], { stdio: 'inherit' });
javascript node.js psexec
Comments
Post a Comment