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.

need more assistance

Old posts that have not been replied to for several years.
Locked
D
Darkj
Halfop
Posts: 86
Joined: Sun Jul 06, 2003 9:58 pm

need more assistance

Post by Darkj »

Ok, I imagine this bug is because my scripts aren't ending properly, but basically here is what is happening:

When i start my bot I can usually DCC to it just fine, and do rehash's etc to adjust scripts. Now I notice if I leave my bot up overnight, and try to DCC it again, it does this:

Waiting for acknowledgement...
DCC Chat connection established
<BotName> Enter your password.

So I enter my password, and nothing, it just sits there, the only way for it to actually work again is I have to restart my bot. Is there a way I can check for errors in my scripts, or ways to check the scripts that haven't exitted properly? Help would be appreciated (I hope I put this in the right forum)
User avatar
TeDDyBeeR
Voice
Posts: 21
Joined: Tue Sep 02, 2003 7:11 am

Post by TeDDyBeeR »

hello Darkj,

Do you have load TCL's whit a loop or someting ?

Code: Select all

 
like : 
 while {$x < $z} {
    ....
 }

or :

 for {set x 0} {$x<10} {incr x} {
     ....
 }
It can happens that the script hangs because he never end in the loops

Also : how did you restarted it agian, just by the partyline command
.restart or just killed the bot on the shell ?

regards...
D
Darkj
Halfop
Posts: 86
Joined: Sun Jul 06, 2003 9:58 pm

Post by Darkj »

I have a couple loops setup,but looking at the code, they should be fine.

And seeing as I can't log into the bot period, I have to kill it from the shell and restart it completely.
User avatar
TeDDyBeeR
Voice
Posts: 21
Joined: Tue Sep 02, 2003 7:11 am

Post by TeDDyBeeR »

Well, try to look good, it can be happend that your bot is hanging in one of the loops.

Maybe a good idea to let me see thous loops, maybe i can help you or searhc for errors or maybe what coust the hang...

regards,
TeDDyBeeR
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Do you have any scripts triggered by a "bind chon"? If not, I bet it's due to unclosed file channels. Are your scripts (the ones reading from files) working when this problem occurs? Check '.tcl file channels' when your bot has been running for a while (should return 'stdin stdout stderr' if everything's fine (and you don't have any script MEANT to leave files open, of course))
If you're logging, did you check your log(s) for errors?
D
Darkj
Halfop
Posts: 86
Joined: Sun Jul 06, 2003 9:58 pm

Post by Darkj »

Ok, after reviewing my scripts, I have narrowed the problem down to when I call this proc through my scripts

Code: Select all

proc parseIni {file} { 
   array set arr {} 
   set f [open $file] 
   while {[gets $f l]>-1} { 
      set l [string trim $l] 
      if {[string match {\[*\]} $l]} { 
         set e [string range $l 1 end-1]
      } elseif {[info exists e]&&[string match *?=?* $l]} { 
         regexp {^([^=]+)=(.+)$} $l a a b 
         lappend arr($e) [string trim $a] [string trim $b] 
      }
   } 
   close $f 
   array get arr 
} 
If this isn't the problem, then I don't know, I got about a billion return's everywhere, and its not fixing it.
D
Darkj
Halfop
Posts: 86
Joined: Sun Jul 06, 2003 9:58 pm

Post by Darkj »

Oh and here is one of the proc's that is causing the bot to leave open files etc

Code: Select all

proc botlist {nick uhost hand chan args} {
  global mainchanbots inifilebots
  if {$chan == $mainchanbots} {
  foreach {name value} [parseIni bots.ini] { 
    set check [ini_read bots.ini ${name} location]
    set displayname [ini_read $inifilebots ${name} display]
    set fs [open botlist.tmp a+]
    puts -nonewline $fs "$displayname "
    close $fs
  }
  set fs [open botlist.tmp r]
   while {[gets $fs line]>-1} { 
       set displayname [lsort -dict [lrange $line 0 end]]
       putquick "PRIVMSG $mainchanbots :\002Loaded Bots\:\002\0032 $displayname\003"
      }
     file delete "botlist.tmp"
     close $fs
     return 0
   } 
   return 0
}
D
Darkj
Halfop
Posts: 86
Joined: Sun Jul 06, 2003 9:58 pm

Post by Darkj »

Oh yea, and the scripts will continue to work, I just can't login to the bot, not even through telnet.

I am getting TONS of file channels left open though, according to .tcl file channels

Wish I had a script to tell me where the holes were though, cuz the way I see it, I have everything closed up tightly.
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Hey! Don't blame my code :P

I recommend rewriting that last proc you pasted...writing the file and reading it and then deleting it from within the same proc makes no sense. and since you delete it before you close it, it's not even deleted :P

Add this to your interpreter to find out who's forgetting to close files:

Code: Select all

if {![string len [info procs open]]} {
	rename open _open
	rename close _close
	proc open {args} {
		if {[info level]>1} {set by [info level -1]} {set by "global"}
		set f [_open openlog.txt a+]
		puts $f "open [join $args] ($by)"
		_close $f
		uplevel 1 [concat _open $args]
	}
	proc close {args} {
		if {[info level]>1} {set by [info level -1]} {set by "global"}
		set f [_open openlog.txt a+]
		puts $f "close [join $args] ($by)"
		_close $f
		uplevel 1 [concat _close $args]
	}
}
It will create a file called 'openlog.txt' with a line for each open and close done. This should make it fairly easy to find out where you've screwed up. Just let the script run for a while and check the file for opens missing closes.
Last edited by user on Wed Sep 03, 2003 8:33 pm, edited 1 time in total.
D
Darkj
Halfop
Posts: 86
Joined: Sun Jul 06, 2003 9:58 pm

Post by Darkj »

Problem solved, spoke to user and found out it was an error in my ini_read, everything is all fixed now, thanks everyone for the help.
Locked