ActiveState Community

How to execute DOS command in a TCL proc?

Posted by TopCat on 2009-01-22 19:25
OS: Windows

Example:
proc foo {path} {
del /q $path\\*.*
}

When i call the proc like this: foo c:\\mydoc, but occur error "invalid command name del". However, i can execute "del" command external of proc.

Anybody help me?

jeffh | Fri, 2009-01-23 15:18

You are relying on the interactive Tcl behavior of the unknown command. You want to use exec, and look at the auto_execok command.

TopCat | Sun, 2009-02-08 20:31

Thank jeffh, i had resolve the problem according to your prompt.