Need some help

Help for those learning Tcl or writing their own scripts.
Post Reply
w
webstar
Voice
Posts: 20
Joined: Tue Mar 09, 2004 3:54 pm

Need some help

Post by webstar »

Ok this is my script, it currently watches a file for changes and then if there is a change it pubishes the file to the channel Right now it's giving errors too many files open plus is there a way for it reuses the same timer rather then a new one everytime.
thanks for any help you can provide.

Code: Select all

############################# 
#  This is the postONE channel 
############################# 

set postONE(chan) "#weatheralerts" 

############################# 
# This is the filename
############################# 

set postONE(filename) "tstormdata.txt" 

############################# 
#  Time between checks in seconds
############################# 

set postONE(time) 30

############################# 
#  Code begin 
############################# 

set postONE(check) 1
set postONE(modtime) [file mtime $postONE(filename)]
set double-help 1

proc postONE_start {} { 
   global postONE 
   set postONE(check) 1
   postONE_check
} 

proc postONE_check {} {
   global postONE 
   if { $postONE(check) == 0 } { return }
   set modtime [file mtime $postONE(filename)]
   set thefile [open $postONE(filename)]
   if { $modtime != $postONE(modtime) } { 

     while { [gets $thefile theline] != -1 } {
       puthelp "PRIVMSG $postONE(chan) :$theline "
     }
     set postONE(modtime) $modtime
     close $thefile
   }
   utimer $postONE(time) postONE_start
}

proc postONE_stop {} {
   global postONE
   set postONE(check) 0
}

postONE_start
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

First off, you only close the file when it was changed.
You should close it no matter what.
w
webstar
Voice
Posts: 20
Joined: Tue Mar 09, 2004 3:54 pm

Post by webstar »

Ok i'll first admit this script was wrote for me, i've edited it a bit but I don't know how to edit it to close the file each time.

FYI
[10:47:30pm] <AlertBot-> [22:43] Tcl error in script for 'timer1025':
[10:47:30pm] <AlertBot-> [22:43] couldn't open "tstormdata.txt": too many open files
[11:03:57pm] <AlertBot-> [23:00] ERROR writing user file.
[12:04:20am] <AlertBot-> [00:00] --- Thu Apr 20 2006

Is the error I get
w
webstar
Voice
Posts: 20
Joined: Tue Mar 09, 2004 3:54 pm

Post by webstar »

anyone?
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

you close the file only conditionally, which is a no-no

as result, your script keeps opening the file without closing it, thus exhausting the limit of open file handles you are allowed on that system
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
Post Reply