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.
Help for those learning Tcl or writing their own scripts.
darton
Op
Posts: 155 Joined: Sat Jan 21, 2006 11:03 am
Post
by darton » Sat Aug 19, 2006 11:08 am
Hello!
I wonder if it is possible to delete a textfile with an eggdrop. With "catch {close [open $fname w]}" you can create a file. Is there a possibility to delete it with another command?
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Sat Aug 19, 2006 11:37 am
yup... using the "file delete" command
NML_375
darton
Op
Posts: 155 Joined: Sat Jan 21, 2006 11:03 am
Post
by darton » Sun Aug 20, 2006 5:16 pm
And can you tell me why this isn't working?
Code: Select all
set fname "scripts/test.txt"
bind pub - !reset m:reset
proc m:reset {nick uhost hand chan arg} {
global fname
if {[file exists $fname]} {
file delete $fname
putquick "PRIVMSG $chan :Done."
} else {
putquick "PRIVMSG $chan :File does not exist."
}
}
It says "Done" but the file isn't deleted.
rosc2112
Revered One
Posts: 1454 Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania
Post
by rosc2112 » Sun Aug 20, 2006 6:05 pm
You could do:
file delete -force $fname
or better:
catch {file delete -force $fname} error
and then check the return value contained in $error to see what's going on.