Skip to content

Instantly share code, notes, and snippets.

@meteormatt
Created January 3, 2014 07:47
Show Gist options
  • Save meteormatt/8234385 to your computer and use it in GitHub Desktop.
Save meteormatt/8234385 to your computer and use it in GitHub Desktop.
模拟Windows命令行
'use strict';
var iconv = require('iconv-lite');
var exec = require('child_process').exec;
var child = exec('dir', function (error, stdout, stderr) {
var str = iconv.encode(stdout, 'GBK');
console.log('stdout: ' + str);
// console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment