Calling a Python Script from TCL Script

Thirukumaran
Thirukumaran Altair Community Member

Hello all,

I have been trying to call a python script located in a directory with Tcl exec command in HyperWorks 2023 which doesn't give me the desired execution. How can I call another .py script from .tcl script file?

Kindly give out some ways to work this out.

Thanks in advance,

Thirukumaran

Tagged:

Answers

  • Akash Purushothaman
    Akash Purushothaman Altair Community Member

    Hi Thirukumaran,

    I just used the below lines for execution and it works for me in HM2023.1


    set pyPath {/path/to/python}

    set scriptPath {/path/to/your/script.py}

    set result [exec $pyPath $scriptPath]

    puts "Output from Python script: $result"

    Here I have not passed any args, but you can also add args based on your need

    Best Regards,
    Akash P