Directory Parse TPS to Make Sure File Isn’t Being Written to

Clovertech Forums Cloverleaf Directory Parse TPS to Make Sure File Isn’t Being Written to

  • Creator
    Topic
  • #119821
    Lane O’Brien
    Participant

      Hello,

      I need to figure out a directory parse proc that checks file size and last modified timestamp. On each iteration, it will check the previous values and if unchanged pick it up and if it’s different, then skip it and check again next time.

      I am having an issue without the proc where Cloverleaf is picking up the files while they are being written to and it is corrupting the file.

      If anyone could help I would be really grateful.

      Thank you,

      James Lane O’Brien

    Viewing 6 reply threads
    • Author
      Replies
      • #119822
        Peter Heggie
        Participant

          Do a search on Directory Parse in this forum – a previous post will have a sample proc you can use. The code reads in an expanded list of files in the specified folder – it includes the file size and date and time. The code compares the file date time with the current date time, and if the difference is greater than X, then that file will be submitted for processing.

          Peter Heggie
          PeterHeggie@crouse.org

          • #119823
            Lane O’Brien
            Participant

              So I am pretty new to TCL I have taken the Cloverleaf class but it has been a little bit since then.

              I tried running a search before making my post but I didn’t see one that I thought would fit my needs. I will look again but if you have the ability to find one easily I would really appreciate it.

              Thank you,

              James Lane O’Brien

          • #119828
            Peter Heggie
            Participant

              ok sure – here is the link to the other article, down towards the bottom is a sample TCL proc that is used as a directory parse proc. There are some helpful facts in there also.

               

              https://usspvlclovertch2.infor.com/forums/topic/want-to-get-date-and-time-from-incoming-file-in-tcl/

              Peter Heggie
              PeterHeggie@crouse.org

            • #119872
              Gene Millard
              Participant

                I am able to get this to work using local drives.

                Is there something special that needs to be set on the path to get it to work for SFTP?

                I get

                could not read “pathname here”
                [pd :pdtd:ERR /0:oracleItemMaster_99:–/–/—- –:–:–] ..
                [pd :pdtd:ERR /0:oracleItemMaster_99:–/–/—- –:–:–] “: no such file or directory’

                Gene Millard

                The Guthrie Clinic
                Sayre, PA

              • #119873
                Peter Heggie
                Participant

                  We do not have the SFTP / secure messaging component of Cloverleaf, so I cannot give you much assistance. But from the output above, it looks like it may be a simple issue of setting the value of the file or folder name variables.

                  Peter Heggie
                  PeterHeggie@crouse.org

                • #119886
                  Robert Kersemakers
                  Participant

                    I don’t think you can do this with an (S)FTP connection.
                    With fileset local you can do this as you are using the OS/tcl commands to check the date/time or other attributes of the file that you are about to process. However with (S)FTP you only have the ftp commands and these don’t have the option to check date/time of the file.

                    I hope I’m wrong Though and someone can show me how to do this.

                    Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

                  • #119887
                    Gene Millard
                    Participant

                      Thank you for your reply. It would be nice if there was a way to make sure the file was not picked up before it was completely written on SFTP.  We are having a problem that some times it picks it up before it is completed and corrupting the file.

                       

                      Gene Millard

                      The Guthrie Clinic
                      Sayre, PA

                    • #119888
                      Levy Lazarre
                      Participant

                        Hello, Gene

                        I believe that what you are trying to accomplish is feasible by simply having the sender sftp the file to Cloverleaf under a temporary name not expected by the Cloverleaf dirparse proc and then use the sftp “rename” command to rename the file to its expected name.

                        For example, if you are waiting for “file.csv”, they could script it as:

                        put file.csv  file.tmp

                        rename file.tmp file.csv

                        Because the ‘rename’ is an atomic operation, you are guaranteed that ‘file.csv’ is a complete file when it becomes available to Cloverleaf.

                        Of course, this assumes that your dirparse proc is looking for specific file patterns and the temp name is not one of them. If your proc is not doing that, then you would have to provide a temporary directory to the sender (with appropriate permissions) to put the temporary file and they would then rename it and move it to the final destination at the same time:

                        rename temp_path/temp_name   final_path/final_name

                        I hope this helps.

                    Viewing 6 reply threads
                    • You must be logged in to reply to this topic.