if {[catch {exec ping [lindex $rest 0] -c 3} ping]} { set ping 1 }
if {[lindex $ping 0] == "0"} { putserv "PRIVMSG $channel :Este Ip ([lindex $rest 0]) está offline"; return 0 }
if {[lindex $ping 0] != "0"} {
putserv "PRIVMSG $channel :Resultado do ping [lindex $rest 0]
:"
... rest of script continues...
This here is the problem. It catches the contents of the ping command into the variable "ping". If it succeeds in getting data, it then overwrites this variable "ping" with 1 which it uses as a flag. The scripter here has broken the script himself. Using a container and flag of the same variable name...
if {[catch {exec ping [lindex $rest 0] -c 3} ping]} { set p 1 } { set p 0 }
if {!$p} {
putserv "PRIVMSG $channel :Este Ip ([lindex $rest 0]) está offline"
return 0
} else {
putserv "PRIVMSG $channel :Resultado do ping [lindex $rest 0]:"
...rest of script continues....
This corrects the flawed variable problem. But doesn't correct those awful lindex on strings, but as nml375 said it's doubtful these cause problems except with nicknames/data containing tcl special characters.
<@Info> !ping www.google.com
<@Eggie> Resultado do ping www.google.com:
<@Eggie> couldn't create error file for command:
<@Eggie> no such file or directory
<@Eggie>
<@Eggie>
<@Eggie>
Hey is the script finally broke? I tried it with the modifications, however just wants to output the "ping useage" with all the variables.. Doesnt give me the results, which I need.
Once that works, I plan to just make it ping a single IP to check if the server is online of offline. If anyone has an idea? Just not sure if this script is fully broke or not now. =/
Edit: Ah HA! After I played around some, its the same line as mentioned above, just had to change the command.