3 Replies Latest reply on Jan 31, 2019 12:25 PM by Alex Gravel

    TPL - Windows list direcotry

    Alex Gravel
      Share:|

      Hi,

       

      I am trying to list the content of a Windows directory.

      The path I am trying to reach is in another partition than the C:\

       

      I see the partition has been discovered.

       

      This is my code :

       

      triggers

           on node := SoftwareInstance created, confirmed 

           where type = 'Software AG webMethods Integration Server';

       

         end triggers;

      body

       

      host := related.host(node);

              log.debug(node.wm_home);

       

      if host.os_class = "Windows" then

       

           myPath := "%node.wm_home%\\IntegrationServer\\instances\\default\\packages";

           log.debug(myPath);

           dirList := discovery.listDirectory(host, myPath);

           for wmServices in dirList do

                if wmServices.file_type = "Directory" then

                     log.debug(wmServices);

                end if;

           end for;

      else

           stop;

      end if;

      end body;

      I get this error on the log for every instance in the dirList :

      businesslogic.base.NodeValue(store_id='\xdeH\xb7W\x14\x0f5\x81s?\xad\xe0', node_id='\xf3IO\\r}\xa6\xd4z\xf3\xce\x15nDiscoveredDirectoryEntry')

       

      I can't find why It doesn't work

      I have done the same thing for a linux host and it as work perfectly

       

      Thanks

        • 1. Re: TPL - Windows list direcotry
          Brian Morris

          Does the log give you a good value for node.wm_home? How about for log.debug(myPath) ?

           

           

          Before you run your for loop, check that you actually got a list of Discovered Directory Entry's back.

           

          So something like:

          ...

          dirList := discovery.listDirectory(host, myPath);

          if dirList then

               for wmServices in dirList do

                    if wmServices.file_type = "Directory" then

                         log.debug(wmServices);

                    end if;

               end for;

          else

          log.debug ("No list of directories was returned, or command failed for directory %myPath%");

          end if;

          ...

          • 2. Re: TPL - Windows list direcotry
            Andrew Waters

            While it is try that you should check for failure the problem you have is that you are logging the node wmServices.

             

            The for loop you have is finding the directories; if you want there names you need wmServices.name, i.e.

            for wmServices in dirList do

              if wmServices.file_type = "Directory" then

                log.debug(wmServices.name);

              end if;

            end for;

            2 of 2 people found this helpful
            • 3. Re: TPL - Windows list direcotry
              Alex Gravel

              Thanks a lot for the qucik reply !

              That did the trick !