Created
April 27, 2015 05:10
-
-
Save hasan3ysf/8050e1ec251068339625 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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