Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

node exec win乱码

$
0
0

最近有个需求在内网服务器上跑几个ping命令测试点东西 在Mac下写完测试了也问题,于是就丢服务器,服务器是win的,发现用exec执行完ping命令返回有乱码

用iconv-lite尝试转gbk还是乱码

各位前辈有遇到过吗?

主要代码如下

var exec = require('child_process').exec;
exec('ping -c3 127.0.0.1', function (err, stdout, stderr) {
    console.log(stdout) // 这里在win下获得的值有乱码
});

Viewing all articles
Browse latest Browse all 14821

Trending Articles