IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Pub.client.sftp:ls

    Posted Thu June 16, 2022 11:19 PM

    Hello,

    I am trying to get files from an SFTP server. Because I need to write log for each file, I get one file at a time. Below is about my steps:

    • pub.client.sftp:ls
      (to find how many files would be download)
      (for the service, we will get a list “dirList”)
    • loop /dirList:
      • pub.client.sftp:get
      • write log

    When I do “pub.client.sftp:ls”, I will get name of both files and directories. However,“pub.client.sftp:get” cannot get directory and will return an error instead.

    How can I distinguish the file or directory? There is a parameter “permission” in dirList. Could I use “permission” to do that?

    Thank you very much!

    webMethods IS version: 10.3.0.0
    Java Version: 1.8.0_202 (52.0)

    Maggie


    #webMethods
    #Integration-Server-and-ESB
    #swebmethods-Protocol-and-Transport


  • 2.  RE: Pub.client.sftp:ls

    Posted Fri June 17, 2022 08:55 AM

    This is the logic I use for these situations:
    image

    In my experience, the dirList/permissions string begins with “d” for the directories and “-” for the files, so the BRANCH with the filter %dirList/permissions%=/^-.*/ only runs for files, and the directories are skipped.


    #swebmethods-Protocol-and-Transport
    #Integration-Server-and-ESB
    #webMethods


  • 3.  RE: Pub.client.sftp:ls

    Posted Fri June 17, 2022 11:23 AM

    Elaborating on “what type of entry is it”, can use this:

    BRANCH on '/dirList/permissions'
    ../^d/: MAP (Directory)
    ../^|/: MAP (Symlink)
    ../^-/: MAP (File)
    ..$default: MAP (Other)
    

    We use this in our own service that wraps pub.client.sftp:ls and adds a couple of other commonly needed features (support for regex, mimic the Unix ls command -a and -A options, sort, limit the number of entries, etc)


    #webMethods
    #Integration-Server-and-ESB
    #swebmethods-Protocol-and-Transport


  • 4.  RE: Pub.client.sftp:ls

    Posted Fri June 17, 2022 08:57 AM

    One quick note: the pub.documents:sortDocuments in the screenshot required in general. I happen to need it for the specific service I grabbed the snippet from.


    #webMethods
    #swebmethods-Protocol-and-Transport
    #Integration-Server-and-ESB


  • 5.  RE: Pub.client.sftp:ls

    Posted Sun June 19, 2022 10:19 PM

    Hi all,

    Thank you for your replying.
    I have tried these solutions and it works successfully!

    Thanks!!

    Maggie


    #swebmethods-Protocol-and-Transport
    #webMethods
    #Integration-Server-and-ESB