Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var exec = require('child_process').exec,
ls;
var stdout = '';
var stderr = '';
ls = exec('tessel run mifareClassic.js', function (error, stdout, stderr) {
if (error) {
console.log(error.stack);
console.log('Error code: '+error.code);
console.log('Signal received: '+error.signal);
}
console.log('test');
console.log('Child Process STDOUT: '+stdout);
console.log('Child Process STDERR: '+stderr);
});
ls.on('exit', function (code) {
console.log('Child process exited with exit code '+code);
});
ls.stdout.on('data', function(buf) {
// console.log('[STR] stdout "%s"!', String(buf));
if(buf.search("Ready") == 0) console.log('swap your card');
if(buf.search("UID") == 0) console.log(String(buf).substring(4));
if(buf.search("Old") == 0) console.log('old %s',String(buf).substring(8));
if(buf.search("New") == 0) console.log('new %s',String(buf).substring(13));
//stdout += buf;
});
ls.stderr.on('data', function(buf) {
// console.log('[STR] stderr "%s"', String(buf));
stderr += buf;
});
ls.on('close', function(code) {
console.log('[END] code', code);
console.log('[END] stdout "%s"', stdout);
console.log('[END] stderr "%s"', stderr);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.