How to execute a batch script within a TCL script

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf How to execute a batch script within a TCL script

  • Creator
    Topic
  • #52894
    Ronald Ortiz
    Participant

      OS: Windows 2008 R2 Standard

      Software:  Cloverleaf 5.8.4 OP

      I’m working on a simple TCL script that will simply execute a batch script.  The batch script works fine when I manually execute it.  I just need to have the TCL script execute it whenever the TCL script is run.  

      The line that is supposed to execute is:

      exec cmd /c E:healthvisioncis5.8integratorbinDaily_SMAT_Cycle.bat

      The issue is that it doesn’t seem to work…nothing is executed and I’m not sure why.  

      Below is the code:

      Code:

      ######################################################################
      # Name:      Cycle_SMAT
      # Purpose:   This TCL script only exists to execute the batch script which performs the cycling of the threads
      # UPoC type: tps
      # Args:      tps keyedlist containing the following keys:
      #            MODE    run mode (”start”, “run”, “time” or “shutdown”)
      #            MSGID   message handle
      #            CONTEXT tps caller context
      #            ARGS    user-supplied arguments:
      #                    
      #
      # Returns:   tps disposition list:
      #            

      #
      # Notes:     Had to do this only because windows scheduler refused to work.
      #
      # History:  
      #                

      proc Cycle_SMAT { args } {
         global HciConnName                             ;# Name of thread
         
         keylget args MODE mode                         ;# Fetch mode
         set ctx “”   ; keylget args CONTEXT ctx        ;# Fetch tps caller context
         set uargs {} ; keylget args ARGS uargs         ;# Fetch user-supplied args

         set debug 0  ;                                 ;# Fetch user argument DEBUG and
         catch {keylget uargs DEBUG debug}              ;# assume uargs is a keyed list

         set module “Cycle_SMAT/$HciConnName/$ctx” ;# Use this before every echo/puts,
                                                        ;# it describes where the text came from

         set dispList {}                                ;# Nothing to return

         switch -exact — $mode {
             start {
                 # Perform special init functions
                 # N.B.: there may or may not be a MSGID key in args
                 
                 if { $debug } {
                     puts stdout “$module: Starting in debug mode…”

                 }
             }

             run {
                 # ‘run’ mode always has a MSGID; fetch and process it
                  exec cmd /c E:healthvisioncis5.8integratorbinDaily_SMAT_Cycle.bat
                 keylget args MSGID mh
                 lappend dispList “CONTINUE $mh”
             }

             time {
                 # Timer-based processing
                 # N.B.: there may or may not be a MSGID key in args
                 
             }
             
             shutdown {
                 # Doing some clean-up work
                 
             }
             
             default {
                 error “Unknown mode ‘$mode’ in $module”
             }
         }

         return $dispList
      }

      [/b]

    Viewing 4 reply threads
    • Author
      Replies
      • #75813
        James Cobane
        Participant

          Ron,

          Try using the ‘eval’ command with your ‘exec’ statement:

          eval exec cmd /c E:healthvisioncis5.8integratorbinDaily_SMAT_Cycle.bat

          The ‘eval’ will pass the exec and its arguments to the Tcl interpreter as a concatenated string for processing

          Also, I’m not sure if you need the ‘cmd’; but I don’t do Windows….so I wouldn’t know for sure.

          Hope this helps.

          Jim Cobane

          Henry Ford Health

        • #75814
          Frank Grube
          Participant

            Hello,

            I make it simple und  it works:

            set ex “C:/quovadx/qdx5.7/integrator/site/scripts/put_xxx_db01.bat”

            exec ${ex}   >>log.txt    2>>err.txt

            OS Windows 2003, Cloverleaf 5.7

          • #75815
            Ronald Ortiz
            Participant

              James Cobane wrote:

              Ron,

              Try using the ‘eval’ command with your ‘exec’ statement:

              eval exec cmd /c E:healthvisioncis5.8integratorbinDaily_SMAT_Cycle.bat

              The ‘eval’ will pass the exec and its arguments to the Tcl interpreter as a concatenated string for processing

              Also, I’m not sure if you need the ‘cmd’; but I don’t do Windows….so I wouldn’t know for sure.

              Hope this helps.

              Jim Cobane

              Henry Ford Health

              Doesn’t seem to work still.

            • #75816
              Ronald Ortiz
              Participant

                Frank Grube wrote:

                Hello,

                I make it simple und

              • #75817
                Ronald Ortiz
                Participant

                  Ronald Ortiz wrote:

                  Frank Grube wrote:

                  Hello,

                  I make it simple und

              Viewing 4 reply threads
              • The forum ‘Cloverleaf’ is closed to new topics and replies.