Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
var exec = require('child_process').exec,
var stdout = '';
var stderr = '';
ls = exec('tessel run mifareClassic.js', function (error, stdout, stderr) {
if (error) {
console.log('Error code: '+error.code);
console.log('Signal received: '+error.signal);
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("Ready") == 0) console.log('swap your card');
if("UID") == 0) console.log(String(buf).substring(4));
if("Old") == 0) console.log('old %s',String(buf).substring(8));
if("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.