Any ideas for handling inbound files with spaces in the name

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Any ideas for handling inbound files with spaces in the name

  • Creator
    Topic
  • #49459
    Steve Williamson
    Participant

      I’m just starting with CL and tcl so please bear with me.

      I’m creating a site where the user will prepare files using Windows based applications, then FTP the files from Windows to a folder on the AIX box where we’re running CL 5.4.

      There I have an Inbound thread using the fileset-local protocol with a TPS defined for the Directory Parse, then a Raw Route using another TPS to read the inbound message and replace it with the properly formatted outbound message.

      Does anyone have any ideas on how to bypass an inbound file if the user FTPs a file with embedded spaces in the file name?

      If the file is named ‘file name.txt’ then the message passed to the directory parse TPS has the value of ‘file name.txt’ then the engine tries to process a file named ‘file’ and another named ‘name.txt’ of course neither of these exist.

      Any help is greatly appreciated.

      Thanks,

      Steve

    Viewing 9 reply threads
    • Author
      Replies
      • #62050
        Jim Kosloskey
        Participant

          Steve,

          Just a stab here but maybe if you take the directory list at the directory parse UPoC and surround the file name with single quotes before returning to Cloverleaf(R) it might work (I seem to recall in UNIX you need to wap single quotes – or maybe it is double quotes around file names with embedded spaces).

          Jim Kosloskey

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

        • #62051
          Steve Williamson
          Participant

            Thanks Jim,

            The problem really stems from the fact that the user may put multiple files in the folder all at once. Some may not have spaces but some may, you know how end-users are. 😯

            If I could count on the file list only having one file I could regsub out the spaces but since I may end up with a file list like

            ‘my file.txt my_other_file.txt’ due to lists being space delimited when I try parse the list I end up with invalid file names and really no fool proof way of preventing it or telling if the space is really the end of the file name or embedded in the file name.

            I may end up giving the user an FTP script to use that will only put files with proper names on the server.

            Steve

          • #62052
            Charlie Bursell
            Participant

              Won’t work Jim.  If you put in a file name like “THIS IS FILE A.TXT”  You will get an error from the fileset driver like:

              [fset:read:ERR /0:    inbound_1:08/13/2007 18:12:21] Cannot open INPUT/THIS for reading: No such file or directory

              I would suggest another way.  IF I had to deal with this I would do it via a UPoC driver.  Just to preclude any errors before I read the files I would do something like:

                    set dir

                    foreach fn [glob -nocomplain [file join $dir *] {

                            set newfn [string map

                $fn]

                              file rename $fn $newfn

                      }

                Then simply raed and process any files found.

            • #62053
              Steve Williamson
              Participant

                Thanks Charlie, that did the trick.

                Steve

              • #62054
                Jim Kosloskey
                Participant

                  Since I have never run into the situation described, I decided to do some investigation.

                  This much I have discovered:

                  the directory parse UPoC is supposed to supply a list of file names which have been found in the directory to which the Fileset protocol is pointed

                  Since Tcl is the extension language we are supposed to use at this UPoC, one would expect the list to be a true Tcl type list such that if we have two files in the directory in question named (the quotes are just for delineation purposes they do not actually exist):

                  ‘filename_no_space’

                  ‘filename with space’

                  I think we would expect to see the following (if we echo the list in the log):

                  filename_no_space {filename with space}.

                  Thus we could get exactly two elements from the list.

                  However (and this is Cloverleaf(R) 5.2), when I have the above situation what I get is:

                  filename_no_space filename with space

                  The above when treated as a list has 4 elements and more importantly will not give correct results.

                  Have I done something wrong or is Cloverleaf(R) not providing a proper list at this UPoC?

                  Jim Kosloskey

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

                • #62055
                  Charlie Bursell
                  Participant

                    Sorry Jim.  The engine was written for Unix which does not allow spaces in file names.  See my response to this same subject.

                    Perhaps you could contact Support and have them write an enhancement request .  But as it now stands fileset/local does not handle file names with spaces

                  • #62056
                    Jim Kosloskey
                    Participant

                      Charlie,

                      I read you previous post but I thought the issue was not with the list being produced by the Directory Parse UPoC (and probable the File Deletion UPoC as well) but rather with the actual I/O routine.

                      Now that I see that is an issue, I will contact support. Frankly I think this should work properly.

                      In my mind, this should probably have been resolved once Cloverleaf(R) was ported to Windows and Windows began supporting file names with spaces (was that Win/95?).

                      In any case, I recall being able to define file names with imbedded spaces in UNIX at least 11 years ago when I was consulting on CA-Unicenter. It caused issues but it could be done. So maybe Cloverleaf(R) should have supported file names with spaces from the beginning.

                      In any case, that was then and this is now.

                      Thanks for verifying that I am not totally insane.

                      Jim Kosloskey

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

                    • #62057
                      James Cobane
                      Participant

                        This is kind of interesting, since I can create a file (on AIX) with spaces in the name, simply by enclosing it with double-quotes; i.e.

                        touch “my file name has spaces.txt”

                        I can then edit it with vi the same way –

                        vi “my file name has spaces.txt”

                        It seems like the engine should be able to handle it.

                        Jim Cobane

                        Henry Ford Health

                      • #62058
                        Jim Kosloskey
                        Participant

                          All,

                          I have reported this situation to Support and have asked that it be treated as a bug not an enhancement.

                          I have also suggested that the correction be made available to all 5.x customers rather than just be corrected in the current and/or next release.

                          Jim Kosloskey

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

                        • #62059
                          Dianna Braden
                          Participant

                            Having a issue with fileset:local erroring when picking up files with spaces in the name.

                            I have read the suggestion on upoc driver – but not sure how that can help reading a directory with files coming into that directory at anytime.

                            Can someone explain?

                            Or example of how to handle spaces in maybe a dirparse tcl

                            I am trying different things

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