egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Delete a file

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
darton
Op


Joined: 21 Jan 2006
Posts: 155

PostPosted: Sat Aug 19, 2006 11:08 am    Post subject: Delete a file Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Aug 19, 2006 11:37 am    Post subject: Reply with quote

yup... using the "file delete" command
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
darton
Op


Joined: 21 Jan 2006
Posts: 155

PostPosted: Sun Aug 20, 2006 5:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Sun Aug 20, 2006 6:05 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber