Tcl and Cron

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Tcl and Cron

  • Creator
    Topic
  • #49591

    I am re-writing a cron scrip from ksh to tcl. I’m having trouble getting my mind wrapped around how to set up the Cloverleaf environment in the tcl script.

    In the arguments I pass the path and site name like this:

       ./db_check.tcl /hci/quovadx/qdx5.2/integrator dev3

    In the script I want to call hcidbdump like this:

       catch { exec hcidbdump -e | grep ‘:’ | wc -l } lines

    So, how to I get the script to exec the hci command on the correct site (dev3)?

    -- Max Drown (Infor)

Viewing 6 reply threads
  • Author
    Replies
    • #62639

      Here is an example code block that doesn’t seem to be working as expected (by me).

      Code:

      #!/hci/quovadx/qdx5.2/integrator/bin/tcl
      # showroot.tcl
      global env
      set hciRoot [lindex $argv 0]
      set hciSite [lindex $argv 1]
      catch { exec /hci/bin/hcisetenv -root tcl $hciRoot $hciSite } catchReturn
      set hciDir $env(HCISITEDIR)
      catch { exec showroot } showroot
      puts $showroot

      Code:

      tcl showroot.tcl /hci/quovadx/qdx5.2/integrator dev3

      Returns …

      Code:

      HCI site is testbn

      Should be …

      Code:

      HCI site is dev3

      -- Max Drown (Infor)

    • #62640
      Steve Carter
      Participant

        This is what I use in my scripts:

        global HciRoot

        eval [exec $HciRoot/sbin/hcisetenv -root tcl $HciRoot $site]

        What you may be missing is the setup of the environment within cron.

      • #62641

        Code:

        global HciRoot

        catch { exec showroot } showroot; puts $showroot

        set hciSite [lindex $argv 0]

        catch { exec /hci/sbin/hcisetenv -root tcl $hciRoot $hciSite } catchReturn
        catch { exec showroot } showroot; puts $showroot

        eval [exec $HciRoot/sbin/hcisetenv -root tcl $HciRoot $hciSite]
        catch { exec showroot } showroot; puts $showroot

        Output (tcl showroot.tcl dev3):

        Code:

        HCI root is /hci/quovadx/qdx5.2/integrator
        HCI site is testbn
        HCI root is /hci/quovadx/qdx5.2/integrator
        HCI site is testbn
        HCI root is /hci/quovadx/qdx5.2/integrator
        HCI site is dev3

        a) What is the difference between ./sbin/hcisetenv and ./bin/hcisetenv ?

        b) Why is the difference in the two exec statements above (catch exec, eval exec)?

        -- Max Drown (Infor)

      • #62642

        Another note …

        I get this message when I try to run a tcl script in cron.

        Code:

        exec(): 0509-036 Cannot load program /hci/quovadx/qdx5.2/integrator/bin/tcl because of the following errors:
               0509-150   Dependent module libtcl8.3.so could not be loaded.
               0509-022 Cannot load module libtcl8.3.so.
               0509-026 System error: A file or directory in the path name does not exist.

        I don’t think we’re using “hci’s cron”. In fact, I have no idea how to use “hci’s cron.” We’re simply doing “crontab -e” from the command line.

        -- Max Drown (Infor)

      • #62643
        Robert Kersemakers
        Participant

          If I remember correctly (no root rights to check this right now) we always switch to user hci when starting a Cloverleaf job from cron. This way all Cloverleaf environment variables are set correctly.

          Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

        • #62644
          Michael Hertel
          Participant

            Max,

            The difference between exec and eval is that:

            exec executes os commands

            eval evaluates a string and executes it as tcl code

            exec $HciRoot/sbin/hcisetenv -root tcl $HciRoot $hciSite executes hcisetenv which is a program that you’ve told to generate tcl code to be eval’d/executed.

            If you run hcisetenv and puts the output, you’ll find that is generates tcl code because you specified tcl. It doesn’t exec on it’s own, just generates the code to be executed.

          • #62645

            Thank you for all the input. Massively helpful. Here’s what I’ve done so far.

            The cron entry which sources a file setting up the environment.

            Code:

            46 * * * * . ~/.profile.cron;/hci/bin/monitor/db_check.tcl sitebn

            .profile.cron

            Code:

            QUOVADX_INSTALL_DIR=/hci/quovadx/qdx5.2
            PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:
               .:/usr/local/bin:/usr/local/lib:/usr/local/scripts:
               ${QUOVADX_INSTALL_DIR}/integrator/sbin:
            export PATH
            setroot

            This seems to be working very well in cron.

            -- Max Drown (Infor)

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