TCL in Crontab Problem

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf TCL in Crontab Problem

  • Creator
    Topic
  • #48114
    Nicole Goodyear
    Participant

    I have a tcl proc that deletes any saved process logs older than 2 months.  I have setup a cronjob that executes this tcl proc but I am getting the following error when it runs:

    /hci/qdx5.1/integrator/ms4test/tclprocs/processLogs.tcl[12]: proc:  not found.

    /hci/qdx5.1/integrator/ms4test/tclprocs/processLogs.tcl[18]: 0403-057 Syntax error at line 20 : `}’ is not expected.

    The crontab looks like this:

    34 11 * * * /usr/bin/ksh -c ‘eval `/hci/qdx5.1/integrator/sbin/hcisetenv -root ksh /hci/qdx5.1/integrator ms4test`;/hci/qdx5.1/integrator/ms4test/tclprocs/proce

    ssLogs.tcl’>/hci/joe/processtestlogs.log 2>&1

    Any thoughts or suggestions on this would be greatly appreciated!

    Thanks

Viewing 8 reply threads
  • Author
    Replies
    • #57682
      Rentian Huang
      Participant

      your crob job looks no problem. have you tested ur processLogs.tcl? use the TPS testing tool, and see whether u still get the same Syntax error. also make sure the proc is in the correct directory.

      sam   8)

    • #57683
      Nicole Goodyear
      Participant

      Thanks for the reply.  The proc does work in the testing tool and it is current directory.  

      Any other ideas?!

    • #57684
      Ricci Graham
      Participant

      Nicole,

      You might try hardcoding the directory structure in the proc so it will find the proc.

      Also, can you post what is on line 20 that it is kicking an error out on?

      Ricci

    • #57685
      Nicole Goodyear
      Participant

      Here is my tcl proc.

      proc processLogs {} {

         set getMonth [fmtclock [getclock] “%m”]

         set deleteMonth 0

         set formatMonth 0

         if {$getMonth != 10 || $getMonth != 11 || $getMonth != 12} {

      set formatMonth [string trimleft $getMonth 0]

         } else {

      set formatMonth $getMonth

         }

         if {[cequal $formatMonth “1”]} {

      set deleteMonth 11

         } elseif {[cequal $formatMonth “2”]} {

      set deleteMonth 12

         } else {

      set deleteMonth [expr $formatMonth – 2]

         }

      #   remove all files that do equal deleteMonth

         rm /hci/process_logs_test/*.$deleteMonth*

      }

      One thing I am confused with, how can hardcoding the directory structure inside the proc find the proc if it cannot access it in the first place?  Could you please clarify? Thanks!

    • #57686
      Ricci Graham
      Participant

      Nicole,

      On the second error, it looks like it thinks you have an extra brace, but when I copy and paste your proc in my editor and check it, all the braces line up, so that is a little strange. Did you remove a brace before posting?

      To answer your questions on clarification, I misunderstood. You’re right, if it can’t find the proc in the first place, it won’t be able to read anything from it.

      Another thought, have you run this proc from the command line and see if it runs? Before I add anything to Cron, I run it from the command line first to see if I get any errors.

      Ricci

    • #57687
      Nicole Goodyear
      Participant

      Hi Ricci,

      I did not remove any curly braces before I posted.  I just tried running this from the command line as root and hci and I am receiving the exact same errors.  

      Thanks,

      Nicole

    • #57688
      Bill Bertera
      Participant

      I think you need to make the file a script and not a procedure. remove the “proc processlogs {”  line, and the final }. Add the tcl intepreter to the first line:

      #!/hci/qdx5.2/integrator/bin/hcitcl

      (or wherever your tcl is).

      make it executable: chmod +x filename.tcl (if you’re on unix).

      and then try to run it.

    • #57689
      Anonymous
      Participant

      If your on a unix system I would recommend making your scripts cloverleaf release independent with the below as the 1st three lines of your script.

      #!/usr/bin/sh

      # reload using exec but make it a comment for tcl

      exec hcitcl “$0” “$@”

      The first line may vary depending on your unix version

      #!/usr/bin/sh  is for aix

      the sh exec will use the environment variables to find hcitcl

      and root must be set

    • #57690
      Nicole Goodyear
      Participant

      Hi Bill,

      That’s it!  Thank you so much for your help 🙂

      Nicole

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

Forum Statistics

Registered Users
5,117
Forums
28
Topics
9,292
Replies
34,435
Topic Tags
286
Empty Topic Tags
10