| View previous topic :: View next topic |
| Author |
Message |
darton Op
Joined: 21 Jan 2006 Posts: 155
|
Posted: Sat Aug 19, 2006 11:08 am Post subject: Delete a file |
|
|
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? |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat Aug 19, 2006 11:37 am Post subject: |
|
|
yup... using the "file delete" command _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
darton Op
Joined: 21 Jan 2006 Posts: 155
|
Posted: Sun Aug 20, 2006 5:16 pm Post subject: |
|
|
And can you tell me why this isn't working?
| Code: | 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. |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Sun Aug 20, 2006 6:05 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
|