Help: Fileset-FTP

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Help: Fileset-FTP

  • Creator
    Topic
  • #47765
    Rentian Huang
    Participant

      Dear cloverleafers,

      I am trying to save a ftped file locally, after grabbing them from a remote server and I have the following error. Attached below is the TPS I put in the TPS Direcotry Parse.

      I appreciate your help in any way,

      Sam 🙂


      “tpsFilesetFilter {MSGID message303} {CONTEXT fileset_ibdirparse} {ARGS {{{FILTER} {chg}} {{NEWPATH}  {/hci/quovadx/qdx5.2/integrator/test_orders_resul…”‘

      05/24/2005 11:46:36 [pd  :pdtd:ERR /0:    sugiChgIn] Tcl error:

             msgId   = message303

             proc    = ‘tpsFilesetFilter’

             args    = ‘{{FILTER} {chg}} {{NEWPATH} {/hci/quovadx/qdx5.2/integrator/test_orders_results/periop_bill}}’

             result  = ‘cp: docs

      chg

      : A file or directory in the path name does not exist.’

             errorInfo: ‘

      cp: docs

      chg

      : A file or directory in the path name does not exist.

         while executing

      “exec cp $data $file_path”

         (“run” arm line 16)


      ######################################################################

      # Name: tpsFilesetFilter

      # Purpose: The TCL proc receives the list of files from the FTP command,

      # selects file that match the pattern from the list and passes the list back.

      # Date/Who 05/10/2005, Sam

      # UPoC type: tps

      # Args: tps keyedlist containing the following keys:

      # ARGS user-supplied arguments:

      # DEBUG – (Optional) “1” Invokes log file entries using log_it and log_it2. Default is “0”.

      # FILTER – pattern to match the files

      #

      proc tpsFilesetFilter { args } {

      keylget args MODE mode

      keylget args CONTEXT context

      if {![keylget args ARGS.DEBUG debug]} { set debug “0” }

      if {![keylget args ARGS.FILTER filter]} { error “No filter argument provided” }

      if {![keylget args ARGS.NEWPATH newpath]} { error “User supplied argument ‘NEWPATH’ not specified” }

      set dispList {}

      switch -exact — $mode {

      start {}

      run {

      keylget args MSGID mh

      set data [msgget $mh ]

      ######## make a copy of inbound file, rename previous file to old is exists ########

      set split_data [split $data “/”]

      set filename [lindex $split_data end]

      set file_path $newpath/$filename

      if [file exists $file_path] {

      set old .old

      set old $file_path$old

      # if file already exist, rename it to *.old

      exec mv $file_path $old

      }

      exec cp $data $file_path

      ####################################################################################

      set return_files {}

      foreach file $data {

      if [string match $filter $file] {

      lappend return_files $file

      }

      }

      msgset $mh $return_files

      lappend dispList “CONTINUE $mh”

      }

      shutdown {}

      time {}

      default {

      error “Unknown mode ‘$mode’ in tps_fileset_dir_parse”

      }

      }

      return $dispList

      }

    Viewing 7 reply threads
    • Author
      Replies
      • #56654
        garry r fisher
        Participant

          Hi,

          I had a similar problem.

          One suggestion is when you rebuild your file path use the ‘file join’ command. Brent Welch in the excellent “Practical Programming in Tcl and Tk” recommends this method as you can hit problems simply joining pathnames using a slash. (p 104 of the 3rd edition refers to this).

          This worked for me.

          Regards

          Garry

        • #56655
          Rentian Huang
          Participant

            Hi Garry,

            I tried: set file_path [file join $newpath $filename]

            But it still gives me the same error..

            The error seems pointing to the $data (which has a value of chg) in:

            exec cp $data $file_path

            Thanks a lot!

            Sam 🙂

          • #56656
            Robert Milfajt
            Participant

              I see two things.

              1)  The $mh variable has all of the files in the directory, so if you only have one, your code will work, but if there is more than one file, with any name, in the directory, you will need to add a loop, i.e.,

                   foreach file $data {

                           The rest of your stuff to process a single file.

                   }

              2)  It looks like you have the foreach loop a little later on, and it may be as simple as moving that foreach command up in the proc just after msgget command.

              Hope this helps,

              Bob   8)

              Robert Milfajt
              Northwestern Medicine
              Chicago, IL

            • #56657
              Rentian Huang
              Participant

                Bob,

                You are absolutely right, fortunately there’s only one file in my stream. I put the loop there, but it still gives me the same error: (I attached the proc)

                A file or directory in the path name does not exist

                Help….

                Sam  ðŸ˜¯

              • #56658
                Robert Milfajt
                Participant

                  Hmmmm…  I have a couple of more ideas to try.

                  You should move the code to create file_path inside the foreach loop, i.e.,

                  Code:

                  keylget args MSGID mh
                  set data [msgget $mh ]

                  foreach file $data {
                  set split_data [split $file “/”]
                  set filename [lindex $split_data end]
                  set file_path [file join $newpath $filename]
                  if [file exists $file_path] {
                  set old .old
                  set old $file_path$old
                  # if file already exist, rename it to *.old
                  exec mv $file_path $old
                  }
                  exec cp $file $file_path
                  }

                  I would put in some debug to return the directory name which the TCL proc is executing in and the value of the variable data.  It could be that you are not getting fully qualified file names and the TCL proc is not executing in the directory where the files in the list are located.  The code may look like:

                  Code:

                  set curdir [pwd]
                  echo “Current directory >$curdir<" echo "File list >$data<"

                  Hope this helps,

                  Bob

                  Robert Milfajt
                  Northwestern Medicine
                  Chicago, IL

                • #56659
                  Rentian Huang
                  Participant

                    Bob, someone told me that I can’t put the cp inside the Deletion TPS:

                    No you can not use the deletion tps because there is no command to give over the ftp connection. You can route the message back to the protocol driver so it gets written in the directory specified as outbound, or you can save a message locally like this:

                       set fo [open $filename w+]

                       fconfigure $fo

                  • #56660
                    Robert Milfajt
                    Participant

                      We were able to copy files from a deletion TPS using:

                      Code:

                      if { [catch {file copy $filename $newfilename} fid] } {
                                         echo “$module: Could not copy $filename to $newfilename”
                                     }

                      But that isn’t the Unix cp, you were trying.  I’m glad you got it to work.  ðŸ˜›

                      Bob

                      Robert Milfajt
                      Northwestern Medicine
                      Chicago, IL

                    • #56661
                      Rentian Huang
                      Participant

                        Thanks a lot Bob, I think your code is a very efficient one too!

                        Good day,

                        Sam  8)

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