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 

Need some help

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
webstar
Voice


Joined: 09 Mar 2004
Posts: 20

PostPosted: Wed Apr 19, 2006 1:46 am    Post subject: Need some help Reply with quote

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
View user's profile Send private message
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Wed Apr 19, 2006 3:47 am    Post subject: Reply with quote

First off, you only close the file when it was changed.
You should close it no matter what.
Back to top
View user's profile Send private message
webstar
Voice


Joined: 09 Mar 2004
Posts: 20

PostPosted: Thu Apr 20, 2006 12:41 am    Post subject: Reply with quote

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
View user's profile Send private message
webstar
Voice


Joined: 09 Mar 2004
Posts: 20

PostPosted: Thu Apr 27, 2006 12:02 am    Post subject: Reply with quote

anyone?
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Thu Apr 27, 2006 12:12 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help 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