title: Using sftp outbound gateway to get a list of files from a remote directory
body: <p>I am trying to do something that I feel is relatively simple and straightforward. I am trying to get a list of files from a specific remote directory, and then figure out what I want to do with the files based on the date.</p>
  
  <p>The issue that I am having is that once the sftp connection is made, and the ls command executes, it seems to always return files from the root directory "/", rather than going to the remote-directory that I have specified. I have tried various iterations of remote-directory, and or expression to get at files from the directory that I want to no avail.</p>
  
  <p>I wish to retrieve files from the remote directory:
  "/sites/cmsftp/site/live/ftp/cmsoss/outbound"</p>
  
  <p>The configuration is:</p>
  
  <pre><code>&lt;int-sftp:outbound-gateway id="remoteftpLS"
                             session-factory="dealerDataSftpSessionFactory"
                             request-channel="sftpRequestChannel"
                             command="ls"
                             remote-file-separator="/"
                             remote-directory="/sites/cmsftp/site/live/ftp/cmsoss/outbound"
                             expression="''"
                             charset="UTF-8"
                             local-directory="${ftpOutputPath}"
                             reply-channel="fileListSplitterInputChannel" /&gt;
  </code></pre>
  
  <p>I have also tried:</p>
  
  <pre><code>&lt;int-sftp:outbound-gateway id="remoteftpLS"
                             session-factory="dealerDataSftpSessionFactory"
                             request-channel="sftpRequestChannel"
                             command="ls"
                             remote-file-separator="/"
                             remote-directory="/sites/cmsftp/site/live/ftp/cmsoss/outbound"
                             expression="payload"
                             charset="UTF-8"
                             local-directory="${ftpOutputPath}"
                             reply-channel="fileListSplitterInputChannel" /&gt;
  </code></pre>
  
  <p>There are no errors here. The first way that I discovered that it was always going to root was when I placed an expression to look for files named a particular way and noticed that I got back an exception stating that there was no such file. Only then did I change the expression to payload, or "''", which returned me a list of files from the root directory. Stopping at a breakpoint in the custom splitter that is downstream from this gateway is how I verified that it is pulling files from the root directory.</p>
  
  <p>Am I missing something obvious?</p>