Created
February 4, 2014 03:15
-
-
Save anonymous/8797615 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; | |
function wew(){ | |
exec("iwlist wlan2 scan|grep -Po '(?<=Address: )\\S+|(?<=Signal level=)\\S+|(?<=ESSID:\")[^\"]+'", test); | |
} | |
function test(error, stdout, stderr) { | |
var out = stdout.replace(/^\s+/mg, ''); | |
out = out.split('\n'); | |
var cells = []; | |
var line; | |
var info = {}; | |
for (var i=0,l=out.length-1,m=1; i<l; i++,m++) { | |
line = out[i]; | |
if(i%3 == 0 && i!=0){ | |
cells.push(info); | |
info = {}; | |
} | |
if(m%3==1) { info['mac'] = line; } | |
else if(m%3==2) { info['signal'] = line; } | |
else if(m%3==0) { info['essid'] = line; } | |
} | |
cells.push(info); | |
// console.log(cells); | |
for (var i in cells) { | |
// console.log("the array: " + cells[i].mac); //"aa", bb", "cc" | |
} | |
return cells; | |
} | |
exports.command = wew; | |
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 reader = require( './file1.js' ); | |
var bang = reader.command(); | |
console.log(bang); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
file1.js, line 32: Return to where? exec calls it -- and ignores the return value. You need to pass the value forward, in a callback to your original code.