We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 35254

Tcl - How to run programs from Tcl?


Is there a way to run non-Tcl commands and programs from a Tcl script.

When running non-Tcl commands from my Tcl script, I receive an 'invalid command name' message.

For example:

I encountered the following error when running a Tcl file with a compxlib command.

invalid command name "compxlib"
while executing
"compxlib -s questa -l verilog -arch all -lib all -w -dir C:\work\"
<file "test.tcl" line 1>


The 'invalid command name' message comes because the program command being executed is not a Tcl command.

Tcl scripts use "exec" to invoke other programs.

For the example above, the error will be removed by adding "exec" as below:

execcompxlib -s questa -l verilog -arch all -lib all -w -dir C:\work\

When attempting to execute an application, exec first searches for the name as it was specified. 

Then, in order, .com, .exe, and .bat are appended to the end of the specified name and it searches for the longer name.  

The user should ensure that the command "executable" being executed is in the system PATH or provide the complete path to the executable within the exec command.

In Windows, in order to execute the shell built-in commands like dir and copy, the caller must prepend `cmd.exe /c' to the desired command.

For example:

exec cmd /c (dir c:\\Xilinx)
AR# 35254
Date 01/18/2017
Status Active
Type General Article
  • ISE
  • Vivado Design Suite