I’m not sure if there’s a more efficient way to do this, though one person once stated they use Win32 API as opposed to io.popen. The problem is, I seem to lack skill to incorporate WinAPI into anything, though I’d love to use that if I could find a detailed, step-by-step instruction on makefile (or whatever I need to do) and making it work. But until then, this is the task at hand.
I’m currently using io.popen to return a ping result within a program that I use The problem is, it pops up the cmd box, and while it does so just briefly, it’s annoying. This is what my code is:
pinghandle = io.popen("ping "..zs.params(2))
pingresult = pinghandle:read("*a")
pingmin = string.match(pingresult,"Minimum = (%d+ms)")
pingmax = string.match(pingresult, "Maximum = (%d+ms)")
pingavg = string.match(pingresult, "Average = (%d+ms)")
pinghandle:close()
if pingmin and pingmax and pingavg then
send(zs.param(1),"@r{@x111Ping to @w"..zs.params(2).." @x111Min: @w"..pingmin.." @x111Avg: @w"..pingavg.." @x111Max: @w"..pingmax.."@r}@w")
else
send(zs.param(1),"@x111Unsuccessful ping to@w",zs.params(2))
end
Pay no attention to the zs.param(#). That’s client specific and has no bearing on the code. My question is… is there an “invisible” way to achieve the same result? Barring that, is this as effective as I can make the code?
There are various external libraries to let you do this for you.
Check out winapi, apr or ex