Need assistance with directory parse TCL

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Need assistance with directory parse TCL

  • Creator
    Topic
  • #52673
    Ian Morris
    Participant

      I’m working with a fileset-local thread.  I need the thread to look for a file name (“Item.Dat”) in a directory.  The problem is that the directory could have more than just Item.Dat inside of it.  Based on another thread in the forum, I pieced the proc below together.  Can someone give me some tips on how I can say, programatically…”Continue monitoring this directory for the correct filename, and if you see it, process the messages in the file.  Ignore all files other than Item.Dat”

      Code:


      proc echoprice { args } {
      set folder “/opt/healthvision/cis5.8/integrator/summit_health/exec/processes/medi_omni1/echo-out”
      set msgs [glob -nocomplain -directory $folder Item.Dat]
      set fillst [split $msgs ” “]
      set len [llength $fillst]
      foreach file $fillst {
      echo “file is $file”
                if {($file eq “/opt/healthvision/cis5.8/integrator/summit_health/exec/processes/medi_omni1/echo-out/Item.Dat”)} {
       echo “filename matches Item.Dat”
                                       #I WANT TO “CONTINUE” THE MESSAGE
                  } else {
        echo “filename $file does not match Item.Dat”
                                       #I WANT TO “KILL” THE MESSAGE
                  }
      }
      }

    Viewing 6 reply threads
    • Author
      Replies
      • #75072
        Jim Kosloskey
        Participant

          Ian,

          If you want to do this in the engine, why not use a Fileset/Local protocol and the dirparse UPoC?

          The protocol will look hwoever often you want and provide you with a list of files it found.

          Then in the dirparse UPoC you can modify that list any way you want – throwing away files you don’t want, adding new file names, sorting the list so that the files process in a certain order, etc.

          I have a proc and package we use for all of dirparse activity (Fileset/Local or Fileset/FTP) and the protocol does the scheduling work.

          Just don’t forget there is a file delete UPoC in those protocols you may want to deploy as well (our package works there as well).

          email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

        • #75073
          Ian Morris
          Participant

            Is there a dirParse tcl proc that comes with the engine?

          • #75074
            Jim Kosloskey
            Participant

              Ian,

              Check $HCIROOT/contrib I think you will find a sample proc there.

              email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

            • #75075
              Ian Morris
              Participant

                None

              • #75076
                Jim Kosloskey
                Participant

                  Ian,

                  What release of Cloverleaf?

                  Somewhere under the $HCIROOT directory there is a contrib directory (maybe a couple). Do a find for *contrib*.

                  email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

                • #75077
                  Ian Morris
                  Participant

                    Jim, I apologize.  I didn’t mean to say “none”.  That was a screw up on my part.

                    I did find the contrib directory where you said it was.  There was an example of reading files in a directory but it wasn’t exactly what I needed.  Thanks to a post by Roman Partigula, I was able to adapt his TCL proc to meet my needs.  I’m attaching the proc for your reference.

                  • #75078
                    Richard Hart
                    Participant

                      Attached is an example from a few years ago where we were loading millions of messages into an application, with the messages stored in SMAT files.

                      The application accepts messages on one thread and ACKs on another.  This code checks and pauses message when there are many message to process.

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