Tcl Event Programming

Clovertech Forums Read Only Archives Cloverleaf General Tcl Event Programming

  • Creator
    Topic
  • #48297
    David Harrison
    Participant

      I need to capture a unix print file but I want to make sure the file has finished being written to. I

    Viewing 3 reply threads
    • Author
      Replies
      • #58275
        garry r fisher
        Participant

          Dave,

          I assume that the date stamp on a print file will be the date/time it was originally written to disk until another application opens it. Once this happens then the modified date/time will change.

          Not sure whether it would work but have you tried checking for an OPEN file? You could run a test on the file to see if it is locked or open for write by another application and only access it yourself once the ‘print’ process has completed.

          Regards

          Garry

        • #58276
          David Harrison
          Participant

            Garry,

            I’m on unix which unlike Windows doesn’t have file locking. This is why I need to check over a period of time to see that it hasn’t been updated. My question was about why the ‘after’ command didn’t appear to execute.

            Thanks,

            Dave

          • #58277
            John Mercogliano
            Participant

              David,

                You need to have the after command on a line by itself.  The way you are writing it, tcl thinks that you want that script to execute after 30000msec.  The first form of after is what you want in this case which is after .

              Try this:

              set i 0

              file stat $fname1 fstat1

              while {$i<5} {

                 incr i

                 after 30000

                 file stat $fname1 fstat2

                 if {$fstat1(mtime) == $fstat2(mtime)} {

                     file copy $fname1 $fname2

                     break

                 } else {

                     file stat $fname1 fstat1

                 }

              }

              Cheers

              John Mercogliano
              Sentara Healthcare
              Hampton Roads, VA

            • #58278
              David Harrison
              Participant

                John,

                That worked; thanks very much for your help.

                Regards,

                Dave

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