egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

!ping ip/host

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
Info
Voice


Joined: 12 Sep 2009
Posts: 3

PostPosted: Sat Sep 12, 2009 6:38 am    Post subject: !ping ip/host Reply with quote

Hi everyone!

I've download a script to ping an ip/host at egghelp.org, but it doesnt work.

Code:
########################################################
# Tcl Feita por MrBoss (MrBoss@BRASnet.org)            #
# A tcl de !ping HOST/IP foi desenvolvida para         #
# pingar o IP/Host pela maquina onde é rodado eggdrop  #
# Além de mostrar a resposta do ping no canal qual o   #
# comando foi digitado.                                #
########################################################
########################################################
# COMANDO VIA CANAL:                                   #
#                                                      #
# !Ping 127.0.0.1  ou !Ping www.linksoft.com.br        #
#                                                      #
########################################################


###########################################################################################
# Não mude nada em baixo , pois a TCL poderá não funcionar corretamente !!!!!!!!!!!!!!!!!!#
###########################################################################################


bind pub - !ping pub_ping

proc pub_ping {nick uhost hand channel rest} {
   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]:"
      putserv "PRIVMSG $channel :[lindex $ping 0] [lindex $ping 1] [lindex $ping 2] [lindex $ping 3] [lindex $ping 4] [lindex $ping 5]"
      putserv "PRIVMSG $channel :[lindex $ping 6] [lindex $ping 7] [lindex $ping 8] [lindex $ping 9] [lindex $ping 10] [lindex $ping 11] [lindex $ping 12] [lindex $ping 13]"
      putserv "PRIVMSG $channel :[lindex $ping 14] [lindex $ping 15] [lindex $ping 16] [lindex $ping 17] [lindex $ping 18] [lindex $ping 19] [lindex $ping 20] [lindex $ping 21]"
      putserv "PRIVMSG $channel :[lindex $ping 22] [lindex $ping 23] [lindex $ping 24] [lindex $ping 25] [lindex $ping 26] [lindex $ping 27] [lindex $ping 28] [lindex $ping 29]"
      putserv "PRIVMSG $channel :[lindex $ping 30] [lindex $ping 31] [lindex $ping 32] [lindex $ping 33] [lindex $ping 34]"
      putserv "PRIVMSG $channel :[lindex $ping 38] [lindex $ping 39] [lindex $ping 40] [lindex $ping 41] [lindex $ping 42] [lindex $ping 43]"
      putserv "PRIVMSG $channel :[lindex $ping 44] [lindex $ping 45] [lindex $ping 46] [lindex $ping 47] [lindex $ping 48] [lindex $ping 49]"
      return 0
   }
}


putlog "Tcl de !Ping IP/Host load"
putlog "!PING By MrBoss v1.0"


What's wrong with this code?
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Sep 12, 2009 8:45 am    Post subject: Reply with quote

It would be very helpful if you could post any logged error messages related to loading/using this script...

One thing that stands out though, is a large number of improper use of the lindex command on strings, although I doubt this is the sole issue...
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Info
Voice


Joined: 12 Sep 2009
Posts: 3

PostPosted: Sat Sep 12, 2009 9:48 am    Post subject: Reply with quote

Eggie just tells me that all IPs and hosts are offline.
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sat Sep 12, 2009 9:50 am    Post subject: Reply with quote

Code:
   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...
Code:
   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.
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
Info
Voice


Joined: 12 Sep 2009
Posts: 3

PostPosted: Sat Sep 12, 2009 9:56 am    Post subject: Reply with quote

<@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>
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Sat Sep 12, 2009 11:04 am    Post subject: Reply with quote

Looks suspiciously like the output I would expect to see if I tried to use such a script on a Windrop.
_________________
I must have had nothing to do
Back to top
View user's profile Send private message
alphaz
Voice


Joined: 26 Jun 2010
Posts: 3

PostPosted: Sun Aug 29, 2010 11:26 pm    Post subject: Reply with quote

the only thing you have to change for this script to work is the following line:
Code:
    if {[catch {exec ping [lindex $rest 0] -c 3} ping]} { set ping 1 }


change set ping 1 to set ping 0 .. and it will work..
this is not the perfect way to build a script.. but it does work..

right now im working with it.. a little bit modified in lindex parts..

Code:
[9:58pm] <!JavieR> !ping 74.125.95.103
[9:58pm] <@Sidekick> Pinging 74.125.95.103 with 64 bytes of data
[9:58pm] <@Sidekick> #1: time=12.0 ms #2: time=11.7 ms #3: time=11.9 ms
[9:58pm] <@Sidekick> 3 packets transmitted, 3 received, 0% packet loss, time 2000ms
Back to top
View user's profile Send private message
Mysticales
Voice


Joined: 18 Oct 2011
Posts: 26

PostPosted: Wed Jun 27, 2012 7:34 pm    Post subject: Reply with quote

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.
Code:
if {[catch {exec ping -c 3 [lindex $rest 0] } ping]} { set ping 0 }


Is how it should be, then adjust the lindex output as needed.
_________________
~Battlez-avec la Mystique?~
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber