exec command in Tcl script excutes silently

1.2k Views Asked by At

I want to execute following command in tcl script. The command relates to a particular tool.

exec tool cut Netlists/$::env(DESIGN_NAME).netlist.v

When the aforementioned command executes on running the tcl script, its corresponding output is not shown on the terminal.

When I try to run this command in tcl shell, it works fine.

Is there any way to print the result on the terminal?

1

There are 1 best solutions below

2
On

If you want the output to be directed to the terminal, you need to add redirections (otherwise the output becomes the Tcl result of the exec command). This is done by appending >@stdout 2>@stderr (you usually want to redirect both output and error streams).

exec tool cut Netlists/$::env(DESIGN_NAME).netlist.v >@stdout 2>@stderr

If you're going to be doing this a lot, it can help to have an assistant procedure:

proc tool {args} {
    # You might do other things here, like logging what command was actually called
    exec tool {*}$args >@stdout 2>@stderr
}

tool cut Netlists/$::env(DESIGN_NAME).netlist.v