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.

using bind to remove a file

Help for those learning Tcl or writing their own scripts.
Post Reply
t
topdawg_b
Voice
Posts: 32
Joined: Sun Dec 07, 2008 7:13 pm

using bind to remove a file

Post by topdawg_b »

I have instruction files i allow people to make. People make mistakes. I need a command that deletes a file. Ive looked. I havent found one yet. I found 1 to remove a directory but not a file
i want to use pubm -|- !remfile del:file then put the command in my proc
thanks
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

file delete command:

Code: Select all

file delete $file
http://www.tcl.tk/man/tcl8.4/TclCmd/file.htm#M12

:>
t
topdawg_b
Voice
Posts: 32
Joined: Sun Dec 07, 2008 7:13 pm

Post by topdawg_b »

that's what i was looking for ty very much.
t
topdawg_b
Voice
Posts: 32
Joined: Sun Dec 07, 2008 7:13 pm

Post by topdawg_b »

im confused this is my proc

#delete the file process

proc del:file {nick user@host handle text} {
set delfile [lindex $text 1].ins
putserv "PRIVMSG $nick :[lindex $text 1] has been removed"
[file delete $delfile]
}

it works like it is but if I place the putserv command beneath the
[file delete $delfile]
the putserv command does not execute. above it, it works fine.
what is it in [file delete $delfile] that stops my process
if I had to execute something after this command how would I?
thanks so much
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

1st:
Don't use lindex like that... $text is a string, not a list (consider using split to convert it into a list).

2nd:
Don't enclose the file command with [] if you do not intend to make use of the return code. Currently, you are trying to execute the return code from the file delete operation as a new command.
The file delete command will always return an empty string, causing your script to try and execute "", which is not a valid command. This will generate an error, and script execution is terminated.

Suggested further reading:
Tcl manual page - Command substitutions
NML_375
t
topdawg_b
Voice
Posts: 32
Joined: Sun Dec 07, 2008 7:13 pm

Post by topdawg_b »

ty for the info I am new to this. it is a lot to consume. info seems to be spread out. I will read. thanks for the help.
Post Reply