Need Directory Parse script help

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Need Directory Parse script help

  • Creator
    Topic
  • #49593
    Carl Duff
    Participant

      Hi all,

      I’m attempting to create my first fileset local directory parse script and am having problems (go figure).

      The directory I’m looking in has multiple files and I only need to grab the one I specify and ignore the rest.

      Does someone have a script that does similar they would be willing to share for reference?

      This forum is invaluable and, as always, I appreciate the help.

    Viewing 1 reply thread
    • Author
      Replies
      • #62647
        James Cobane
        Participant

          Carl,

          There is a sample script in the $HCIROOT/contrib directory.  You should be able to look at that and modify to fit your needs.  You’ll just need to add some logic to only look at files with certain names.  For reference, I’ve attached a proc that has a FILTER argument that is used to only pass filenames that match (the FILTER argument) onto the engine for processing.

          Hope this helps.

          Jim Cobane

          Henry Ford Health

        • #62648
          Gary Atkinson
          Participant

            Here is another proc you might find useful:

            Code:


            ######################################################################
            # Name:        fset_ib_dirParse_regexp
            # Purpose: Demonstrate the use of the directory parse tps
            # within the fileset driver.  This proc processes
            # files matching or not matching a pattern
            # the filenames specified in the configuration
            # inbound read directory.
            # UPoC type: tps
            # Args: tps keyedlist containing the following keys:
            #       MODE    run mode (”start”, “run” or “test”)
            #       MSGID   message handle
            #       ARGS    PATTERN  PROCESS
            #          
            #
            # Returns: tps disposition list:
            #          Returns a list of messages for the fileset
            #   driver to process.
            #

            proc fset_ib_dirParse_regexp { args } {
               keylget args MODE mode               ;# Fetch mode

               switch -exact — $mode {
                   start {
                       # Perform special init functions
               # N.B.: there may or may not be a MSGID key in args
                   }

                   run {
               # ‘run’ mode always has a MSGID; fetch and process it
                       keylget args MSGID mh
               keylget args CONTEXT ctx
               #
               # Check for correct context
               #
               if {![cequal $ctx “fileset_ibdirparse”]} {
            echo “ERROR proc used in wrong context”
            echo “Context should be fileset_ibdirparse”
            echo “Proc called in: $ctx”
            return “{CONTINUE $mh}”
            }

            #    In this  context what is  handed to this proc
            #    by the driver is not a data message.  Rather
            #    it is a space seperated string of file names
            #    from the directory the fileset driver is
            #    configured to read.  

               set ib_list [msgget $mh]
               
            #    This proc takes 2 user arguments.  The first argument
            #    specifies a pattern to match against.  The second
            #    argument tells the proc to either process all files
            #    in the directory matching the PATTERN value by passing
            #    a 1 as an argument, or to process all files in the directory
            #    except execpt those matching the PATTERN value by passing
            #    it a 0.
            #    
            #    For example to process all files in a directory containing
            #    the string foo you would pass this argument to this
            #    proc in the Directory Parst TPS:
            #        {PROCESS 1} {PATTERN foo}
            #    If you wanted to process all files execpt for a file named
            #    dummy pass this argument
            #        {PROCESS 0} {PATTERN dummy}

               keylget args ARGS.PATTERN pattern
               keylget args ARGS.PROCESS process
               set out_list “”
               if { ! $process } {
            foreach i $ib_list {
               if { ! [regexp — $pattern $i] } {
            lappend out_list $i
               }
            }
               } else {
            foreach i $ib_list {
               if { [regexp — $pattern $i] } {
            lappend out_list $i
               }
            }
               }
                 
               msgset $mh $out_list
            lappend returnList “CONTINUE $mh”
            return $returnList
            }
                   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 fileset_dir_parse”
                   }
               }
            }

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