TCL Opinions wanted – file reading/writing

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf TCL Opinions wanted – file reading/writing

  • Creator
    Topic
  • #48222
    Anonymous
    Participant

      I have an interface that I think I’m going to have to read/write to a file in the Xlate.  So I want my TCL doing the reading/writing as efficient as possible.

      My question is:  Is it more efficient to use redirection, or to use the TCL file commands to do this?

    Viewing 7 reply threads
    • Author
      Replies
      • #58045
        Anonymous
        Participant

          Matt,

          How do you mean redirection?

          Greg

        • #58046
          Anonymous
          Participant

            By using redirection, like:

            exec ls > jml.txt

            instead of tcl commands:

            set fileid [open jml.txt w]

            puts $fileid [exec ls]

            close $fileid

          • #58047
            Anonymous
            Participant

              I’m open to correction on this point but I believe that when you exec TCL creates a subprocess to contain the running program.  I assume this means a shell.  The file command executes directly from TCL so it should be faster.  If I have time I may test it…

              Cheers,

            • #58048
              Richard Hart
              Participant

                Matt.

                I would be very surprised so find an ‘exec’ running quicker than ‘in-line’ code as the exec has to perform similar file ops AND start its own process.

                If you are using files to read/write, be careful to ensure that a file is not being read at the same time it is written.

                We use one ‘file’ interface and we timestamp the output file to the nearest hour.  The ‘read’ process runs an hour ‘behind’ to avoid conflict.

              • #58049
                Anonymous
                Participant

                  Your point is well taken.  Thank you both very much.

                • #58050
                  Brad Dorr
                  Participant

                    Matt,  in another discussion you mentioned that you have a WEB front end.  I am in the processes of doing that.  I have loaded Apache onto our Unix server.  I have created some simple cgi scripts to run a hciconnstatus command return the results.  I would like to be able to run a tcl script.  You mentioned that you called the tcl script from the cgi script how can you send me an example?

                  • #58051
                    Vamshi Mugu
                    Participant

                      Hi Matt and Brad,

                      Please post the web stuff to the board. I am interested in it too.

                      thanks,

                      vamshi.

                    • #58052
                      Tom Patton
                      Participant

                        I use the tcl file commands only because I want more control over how I open e.g. appends etc., and lock contention so I can handle the errors (if any).

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