Renaming OB file using tclproc

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Renaming OB file using tclproc

  • Creator
    Topic
  • #53747
    Matthew Laskin
    Participant

      I’m writing an outbound file from a thread, and I need to have the date in the filename, e.g. FILE_01012013_OUT.txt.  I’ve found earlier threads on this forum with the tcl code required, and I’ve adapted for what I need but I can’t get it to work.  I think that it may have to do with where I’m placing the proc, because any echo statements I have in the proc aren’t writing to the logs (or maybe I’m wrong to expect that it would).  Below is the tclproc I’m running.

      Code:

      proc renameFile { 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 “renameTALX/$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
                 keylget args MSGID mh

      set timeVal [clock format [clock seconds] -format %m%d%y]
      set new_out_file “FILE_${timeVal}_OUT.txt”
         set dvr_ctl_str “{FILENAME $new_out_file}”
      echo $new_out_file
         msgmetaset $mh DRIVERCTL $dvr_ctl_str
                 
                 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
      }

      The inbound thread is fileset-local and the outbound is file-local, and I’ve placed the tclproc in the Outbound thread’s outbound tab under “TPS Outbound Data”.  Just to confirm, I should expect the file name to write out to the process directory?

    Viewing 7 reply threads
    • Author
      Replies
      • #78816
        David Harrison
        Participant

          Change this line

          Code:

          set dvr_ctl_str “{FILENAME $new_out_file}”

          to this

          Code:

          set dvr_ctl_str “{FILESET $new_out_file}”

          and put it in the outbound tab in TPS Outbound Data.

        • #78817
          Matthew Laskin
          Participant

            Tried your suggestion, but it still didn’t work.  Thanks, though 😀

          • #78818
            Jim Kosloskey
            Participant

              Matthew,

              Is your outbound protocol file not fileset/local?

              If so, I am not sure what you are trying to do works with file protocol. Try changing your outbound protocol to fileset/local and see if you have better success.

              If you still have issues, email me and I will send you a proc we use which you can use or just reference.

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

            • #78819
              Matthew Laskin
              Participant

                I was testing this tclproc on a pair of new threads I had created for the purpose of trying to get this proc to work, but once I just added the proc to my working threads with translation I see progress.  Now, the file is written out as defined in the protocol details, but the tcl renaming still isn’t getting done. When I check the logs, I see the following:

                Code:

                [fset:wrte:ERR /0:      to_talx:07/24/2013 16:23:59] ‘15424_072413_tstin.v5’ does not match ‘key value’
                File successfully copied.
                [cmd :cmd :INFO/0:    batch_cmd:07/24/2013 16:23:59] Receiving a command
                [cmd :cmd :INFO/0:    batch_cmd:07/24/2013 16:23:59] Command client went away.  Closing connection.
                15424_072413_tstin.v5
                [fset:wrte:ERR /0:      to_talx:07/24/2013 16:24:21] ‘15424_072413_tstin.v5’ does not match ‘key value’

                15424_072413_tstin.v5 is the real filename I’m trying for, instead of the generic one I originally referenced in this thread.  Does this have  something to do with how I’m trying to set the key in msgmetaset?

              • #78820
                Marc Pleijers
                Participant

                  Hi Matthew

                  You should protcol fileset local and use the following piece of TCL in your script to correctly set the metadata.

                  assuming that your new filename is in variable $newfilename

                    # set the filename

                             set driverctl “{FILESET {{OBFILE $newfilename}}}”

                             msgmetaset $mh DRIVERCTL $driverctl

                  regards,

                  Marc[/code]

                  Marc Pleijers
                  Senior Integration Consultant
                  Enovation BV
                  The Netherlands

                • #78821
                  Matthew Laskin
                  Participant

                    Thanks, Dave, Jim and Marc.  With your collaboration, I was able to get the tclproc working.   8)

                  • #78822
                    Jim Kosloskey
                    Participant

                      Why aren’t you using keylset for setting the keyed list – takes care of the curly braxces for you?

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

                    • #78823
                      Matthew Laskin
                      Participant

                        No specific reason – I used snippet from tcl code I found somewhere else..

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