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.

Delete a file

Help for those learning Tcl or writing their own scripts.
Post Reply
d
darton
Op
Posts: 155
Joined: Sat Jan 21, 2006 11:03 am

Delete a file

Post by darton »

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

Post by nml375 »

yup... using the "file delete" command
NML_375
d
darton
Op
Posts: 155
Joined: Sat Jan 21, 2006 11:03 am

Post by darton »

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.
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

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