Lee*_*Lee 9 stdout child-process node.js
我正在编写一些node.js脚本来启动子进程.代码段如下.
var spawn = require('child_process').spawn;
var child = spawn ('node', ['script.js'])
child.stdout.on('data',
function (data) {
logger.verbose('tail output: ' + JSON.stringify(data));
}
);
child.stderr.on('data',
function (data) {
logger.error('err data: ' + data);
}
);
Run Code Online (Sandbox Code Playgroud)
脚本运行良好,除了子进程的stdout和stderr只打印数字输出:
样本输出:
108,34,44,34,105,110,99,114,101,97,109,101,110,116,97,108,95,112,111,108,108,105
Run Code Online (Sandbox Code Playgroud)
如何将这些数值转换为可读字符串?
谢谢.