mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
Fix Ping exec calls so regex can then do it's job...
This commit is contained in:
parent
fe04286d10
commit
914885dd6b
@ -26,14 +26,14 @@ function PingNode(n) {
|
|||||||
|
|
||||||
node.tout = setInterval(function() {
|
node.tout = setInterval(function() {
|
||||||
var ex;
|
var ex;
|
||||||
if (plat == "linux") ex = spawn('ping', ['-n', '-w 5', '-c 1', node.host]);
|
if (plat == "linux") ex = spawn('ping', ['-n', '-w', '5', '-c', '1', node.host]);
|
||||||
else if (plat.match(/^win/)) ex = spawn('ping', ['-n 1', '-w 5000', node.host]);
|
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 if (plat == "darwin") ex = spawn('ping', ['-n', '-t', '5', '-c', '1', node.host]);
|
||||||
else node.error("Sorry - your platform - "+plat+" - is not recognised.");
|
else node.error("Sorry - your platform - "+plat+" - is not recognised.");
|
||||||
var res = "";
|
var res = "";
|
||||||
ex.stdout.on('data', function (data) {
|
ex.stdout.on('data', function (data) {
|
||||||
//console.log('[ping] stdout: ' + data.toString());
|
//console.log('[ping] stdout: ' + data.toString());
|
||||||
var regex = /time=(.*)ms/;
|
var regex = /time.(.*)ms/;
|
||||||
var m = regex.exec(data.toString())||[""];
|
var m = regex.exec(data.toString())||[""];
|
||||||
res = Number(m[1]);
|
res = Number(m[1]);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user