How to pass arguments from cmd to tcl script of ModelSim

I run Modelsim in the cmd from a python program. I use the following code which call a tcl script which run the modelsim:

os.system("vsim -c -do top_tb_simulate_reg.tcl " )
The tcl script contain the following:

vsim -voptargs=“+acc” +UVM_TESTNAME=test_name +UVM_MAX_QUIT_COUNT=1 +UVM_VERBOSITY=UVM_LOW -t 1ps -L unisims_verm -L generic_baseblocks_v2_1_0 -L axi_infrastructure_v1_1_0 -L dds_compiler_v6_0_12 -lib xil_defaultlib xil_defaultlib.girobo2_tb_top xil_defaultlib.glbl
I want that the value of the +UVM_TESTNAME will be an argument which I passed from the cmd when I execute:

os.system("vsim -c -do top_tb_simulate_reg.tcl " )
How can I do it?

I tried the following with no succees:

Python script:

os.system(“vsim -c -do top_tb_simulate_reg.tcl axi_rd_only_test” )
Simulation file (tcl script)

vsim -voptargs=“+acc” +UVM_TESTNAME=$argv +UVM_MAX_QUIT_COUNT=1 +UVM_VERBOSITY=UVM_LOW -t 1ps -L unisims_verm -L generic_baseblocks_v2_1_0 -L axi_infrastructure_v1_1_0 -L dds_compiler_v6_0_12 -lib xil_defaultlib xil_defaultlib.girobo2_tb_top xil_defaultlib.glbl

I got the following error:

** Error: (vsim-3170) Could not find ‘C:/raft/raftortwo/girobo2/ver/sim/work.axi_rd_only_test’.

In reply to saritr:

I’ve had some success with something like:

vsim -c -do “do top_script.tcl option1 option2”

You’d have to package that into your os.system() command and escape the quotes.

In reply to jlivermore:

What do you mean by escape the quotes?

In reply to saritr:

My example uses quotes, but in your python command you would end up with quotes within another set of quotes. So you need a way for the inner quotes to be interpreted literally.

In Python, an easy way around this is to use single quotes as the outer quotes. So in your case, you can try:

os.system('vsim -c -do “do top_tb_simulate_reg.tcl axi_rd_only_test” ’ )

Escaping quotes is often done with backslash before the quote, so it is interpreted as a literal character, and not the end of your string.
https://learnpythonthehardway.org/book/ex10.html