i have a grep function that i am using to seperate some data out.
I ran into an issue, instead of outputting the data to the console, i need it to store it to a variable.
for example, here is my actual function.
function funGrep(cmd,callback,search,args){
exec(cmd,function(err,stdout){
if(!stdout)
return;
var lines = stdout.toString().split(EOL);
var re = new RegExp(search,args);
for(var line in lines){
var results = lines[line].match(re);
if(results){
for(var i = 0; i < results.length; i++){
callback(results[i]);
}
}
}
});
}
and here is my actual calling of the function into play.
funGrep("ping -n 3 google.com",console.log,"time=[0-9\.]+ ?ms");
instead of logging the output to the console, how can i just assign it to a variable like output.
thank you!