This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

!ping ip/host

Support & discussion of released scripts, and announcements of new releases.
Post Reply
I
Info
Voice
Posts: 3
Joined: Sat Sep 12, 2009 6:25 am

!ping ip/host

Post by Info »

Hi everyone!

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

Code: Select all

########################################################
# 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?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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
I
Info
Voice
Posts: 3
Joined: Sat Sep 12, 2009 6:25 am

Post by Info »

Eggie just tells me that all IPs and hosts are offline.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

   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: Select all

   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.
I
Info
Voice
Posts: 3
Joined: Sat Sep 12, 2009 6:25 am

Post by Info »

<@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>
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

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
a
alphaz
Voice
Posts: 3
Joined: Sat Jun 26, 2010 2:56 pm

Post by alphaz »

the only thing you have to change for this script to work is the following line:

Code: Select all

    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: Select all

[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 
M
Mysticales
Voice
Posts: 26
Joined: Tue Oct 18, 2011 5:33 pm

Post by Mysticales »

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: Select all

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?~
Post Reply