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.

stange results with file access

Discussion of Eggdrop's code and module programming in C.
Post Reply
t
topdawg_b
Voice
Posts: 32
Joined: Sun Dec 07, 2008 7:13 pm

stange results with file access

Post by topdawg_b »

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: Select all

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
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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: Select all

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
Post Reply