I have the following tcl script:
puts "The total number of arguments is $argc"
if {$argc > 0} {puts "The arguments in ARGV are: $argv" }
exec python $argv/../scripts/sim/sim_comp_gen.py
How can I exec the python script ans pass it the $argv?
The {*} syntax is key here:
exec python ../scripts/sim/sim_comp_gen.py {*}$argv
If you're making it relative to the name of the script, that's in $argv0 and Tcl has some built-in utilities for making that easier:
set script [file join [file dirname $argv0] scripts/sim/sim_comp_gen.py]
exec python $script {*}$argv
You might need file nativename on Windows. (I can't remember if python does the slash-type ignoring/conversion.)
set script [file join [file dirname $argv0] scripts/sim/sim_comp_gen.py]
exec python [file nativename $script] {*}$argv
On a very old version of Tcl that doesn't support {*}? Use eval carefully…
set script [file join [file dirname $argv0] scripts/sim/sim_comp_gen.py]
eval [list exec python $script] $argv
The key is to use list to de-fang things. That works even when you've got tricky things like spaces in filenames.