How to execute a tcl script in an existing HM session whose PID is known

Saumya4Mishra
Saumya4Mishra Altair Community Member
edited October 2020 in Community Q&A

Hi all,

 

I wanna run some script in my already opened HM session. Is there any way we can access the HM session and execute the tcl script?

NOTE:  I have the HM Session PID where I wanna run the script

 

Regards

Saumya

Tagged:

Answers

  • tinh
    tinh Altair Community Member
    edited May 2019

    Yes, your hm session must work as a server. Use dde or socket command

     

  • Saumya4Mishra
    Saumya4Mishra Altair Community Member
    edited May 2019

    hi tinh

     

    can you kindly explain through an example?

     

  • tinh
    tinh Altair Community Member
    edited October 2020
    https://community.altair.com/community?id=community_question&sys_id=ae5688f61b2bd0908017dc61ec4bcb52

     

     

     

    Refer above.

     

    In your case, this way may be simpler:

    Your hm session (eg. with pid 1234) must pre-run a timer (write it in c:/users/name/hmcustom.tcl)

     

    That timer checks a file eg. 1234.tcl

    If file existing, source it, then clear the file!

     

    So everytime you want to excute a script, put it in 1234.tcl

     

    A such timer:

    proc ::p_MonitorFile {{path {}}} {

       set path_ $path

       after cancel [list ::p_MonitorFile $path_]

       if {$path==''} {

          set path [file join $::env(HOME) [pid].tcl]

       }

       if {[file exists $path]} {

           catch {source $path} err

           file delete $path

           puts 'Executed $path got $err'

       }

       after 3000 [list ::p_MonitorFile $path_]

    }

  • Saumya4Mishra
    Saumya4Mishra Altair Community Member
    edited May 2019

    hi tin

     

    That works . Thanks for the help