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 

stange results with file access

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Modules & Programming
View previous topic :: View next topic  
Author Message
topdawg_b
Voice


Joined: 07 Dec 2008
Posts: 32

PostPosted: Sun Mar 01, 2009 10:06 am    Post subject: stange results with file access Reply with quote

i have a file called ftaserv.tcl when i access this tcl to make a change with gedit when i save the file. a hidden file appears called ftaserv.tcl~ and the changes i made dont take affect. if i access this new file and make the changes in it. another hidden file opens called ftaserv.tcl~~ etc... this same script accesses a file in the eggdrop dir called triggers.txt. I access this file with
Code:

proc trig:add {nick user@host handle text} {
putserv "privmsg #just :this is a test"
putserv "privmsg topdawg :this is another test"

set thestb [lindex $text 1]

set in [open "triggers.txt" r]

set data [read $in]

set line [split $data \n]

set here [lsearch [string tolower $line] "$thestb *"]

if {$here != -1} {putserv "privmsg $nick :$thestb already on file. use .trigupd $thestb address";return}

close $in



set out [open "triggers.txt" a]

puts $out [lrange $text 1 end]

close $out

}

if i access this with .trigadd newtest this is a test.
the first time it accepts it. if I do it again it says already on file like its suppose to. however there is nothing in the file and none of the other scripts can access the newly added info. been looking at it for hours. this was working fine yesterday. and still works fine on my other bot. (on a different box). im really confused. thanks in advance
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2853

PostPosted: Sun Mar 01, 2009 1:26 pm    Post subject: Reply with quote

The ~-file is merely a temporary cache created by gedit, partly to allow you to resume editing upon a crash without having to save every 2 seconds. I assume you remembered to save in gedit, and .rehash/.restart in eggdrop?

Are there any other functions/scripts/programs accessing that triggers.txt file? Most linux and *bsd systems allows one file to be opened in multiple instances under certain conditions. More so, one may open a file for writing while some other process has opened it for reading. In this case, the other process will not see your changes until it closes the file and opens it again for reading.

This is flawed (yet unrelated to your issues):
Code:
set thestb [lindex $text 1]
#use this instead
set thestb [lindex [split $text] 1]

#Same goes for this line
puts $out [lrange $text 1 end]

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Modules & Programming 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