title: Store output of command in sftp to variable and list
body: <p>My aim is to create a shell script such that it logins and filter the list of files available and select a file to get. Here I need to run commands like in bash.
  My sample code is:</p>
  
  <pre><code>sshpass -p password sftp user@10.10.10.10 &lt;&lt;EOF
  cd /home/
  var=$(ls -rt)
  echo $var
  echo "select a folder"
  read folder
  cd $folder
  filen=&amp;(ls -rt)
  echo $filen
  echo "select a file"
  read name
  get $name
  bye
  EOF
  </code></pre>