Fix ping error response on Pi - Fixes Issue #23

This commit is contained in:
Dave C-J
2014-02-05 18:36:29 +00:00
parent fb78085d4c
commit 2f07bb7d13
2 changed files with 4 additions and 6 deletions

View File

@@ -30,12 +30,12 @@ function PingNode(n) {
else if (plat.match(/^win/)) ex = spawn('ping', ['-n', '1', '-w', '5000', node.host]);
else if (plat == "darwin") ex = spawn('ping', ['-n', '-t', '5', '-c', '1', node.host]);
else node.error("Sorry - your platform - "+plat+" - is not recognised.");
var res = "";
var res = false;
ex.stdout.on('data', function (data) {
//console.log('[ping] stdout: ' + data.toString());
var regex = /time.(.*)ms/;
var m = regex.exec(data.toString())||[""];
res = Number(m[1]);
var regex = /from.*time.(.*)ms/;
var m = regex.exec(data.toString())||"";
if (m != '') { res = Number(m[1]); }
});
ex.stderr.on('data', function (data) {
//console.log('[ping] stderr: ' + data);