Skip to content

Instantly share code, notes, and snippets.

@flexd

flexd/grabber.js Secret

Created October 8, 2012 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flexd/59551b61c9eac6f3df68 to your computer and use it in GitHub Desktop.
Save flexd/59551b61c9eac6f3df68 to your computer and use it in GitHub Desktop.
var spawn = require('child_process').spawn,
reader = spawn('python', ['uidgrabber.py']);
var util = require('util');
console.log("uidgrabber running pid: " + reader.pid);
reader.stdout.on('data', function (data) {
console.log('stdout: ' + data);
var data = data.toString();
data = data.replace(/\u001b\[\d{0,2}m/g, ''); // Remove ANSI colors.
var uid = /UID: (.+)/.exec(data);
if (uid) {
uid = uid[1];
lastUID = uid;
console.log("UID: " + uid);
}
});
reader.stdout.on('end', function (data) {
console.log('stdout end: ' + data);
});
reader.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
reader.on('exit', function (code) {
console.log('uidgrabber process exited with code ' + code);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment