I was wondering if someone could write me a smallt tcl script that would do the following:
1) Every 4 secs "Text.txt" is read - and messaged into a channel
2) Once the text has been read, the contents are deleted
3) If there's no contents in the Text, then nothing happens.
Any help would be greatly appreciated.
Thanks.
Edit: This is for an eggdrop
Edit2:
i had a mini go at it, just from cutting other scripts - unsure though if its correct, or how to put it on a timer:
Code: Select all
#reading
set fname "yourfile.txt"
set fp [open $fname "r"]
set data [read -nonewline $fp]
close $fp
set lines [split $data "\n"]
#messaging
set wchan #Chan
global wchan {
putserv $lines
}
#deleting
set match *
while {[set i [lsearch -glob $lines $match]]>-1} {
set lines [lreplace $lines $i $i]
}
#writing file
set fp [open $fp "w"]
puts $fp [join $lines "\n"]
close $fp