Currently, I have an alias as follows:
This works properly, except it opens up a command window, which freezes game play for a few seconds while it executes the command.
Last night, I came across utils.shellexecute, and thought this might be a great substitute for os.execute, so I decided to play with it. However, I cannot seem to get it to work. If I try:
... then it works. But I need to store the results in a text file, and when I try:
... in place of the os.execute, it doesn't seem to generate the text file, evidenced the by error I get that there is nothing to be read.
I've also tried, to no avail:
Is there a way I can accomplish what I want? Or is this just a fruitless venture?
<aliases>
<alias
match="^ping (.*?) (.*?)$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>n = "C:/MUSHClient/pingresults.txt"
pingmin, pingmax, pingavg = nil, nil, nil
os.execute("ping %2 > " .. n .. " &")
for line in io.lines(n) do
if string.find(line, "Minimum =") then
pingmin = string.match(line, "Minimum = (%d+ms)")
end
if string.find(line, "Maximum = ") then
pingmax = string.match(line, "Maximum = (%d+ms)")
end
if string.find(line, "Average =") then
pingavg = string.match(line, "Average = (%d+ms)")
end
end
if pingmin and pingmax and pingavg then
Send("%1 @r{@x111Ping to @W%2 @x111Min: @w" .. pingmin .. " @x111Avg: @w" .. pingavg .. " @x111Max: @w" .. pingmax .. "@r}$C")
else
Send("%1 @r{@x111Unsuccessful ping to @w%2@r}$C")
end
os.remove(n)</send>
</alias>
</aliases>
This works properly, except it opens up a command window, which freezes game play for a few seconds while it executes the command.
Last night, I came across utils.shellexecute, and thought this might be a great substitute for os.execute, so I decided to play with it. However, I cannot seem to get it to work. If I try:
utils.shellexecute("ping", "aardmud.org")
... then it works. But I need to store the results in a text file, and when I try:
utils.shellexecute("ping", "%2 > " .. n .. " &", GetInfo(68), "open", 0)
... in place of the os.execute, it doesn't seem to generate the text file, evidenced the by error I get that there is nothing to be read.
I've also tried, to no avail:
utils.shellexecute("cmd", "ping %2 > " .. n .. " &", GetInfo(68), "open", 0)Is there a way I can accomplish what I want? Or is this just a fruitless venture?