| View previous topic :: View next topic |
| Author |
Message |
webstar Voice
Joined: 09 Mar 2004 Posts: 20
|
Posted: Wed Apr 19, 2006 1:46 am Post subject: Need some help |
|
|
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: |
#############################
# 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 |
|
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Wed Apr 19, 2006 3:47 am Post subject: |
|
|
First off, you only close the file when it was changed.
You should close it no matter what. |
|
| Back to top |
|
 |
webstar Voice
Joined: 09 Mar 2004 Posts: 20
|
Posted: Thu Apr 20, 2006 12:41 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
webstar Voice
Joined: 09 Mar 2004 Posts: 20
|
Posted: Thu Apr 27, 2006 12:02 am Post subject: |
|
|
| anyone? |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Thu Apr 27, 2006 12:12 am Post subject: |
|
|
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] tag when posting logs, code |
|
| Back to top |
|
 |
|