title: How to execute multiple commands on remote server and get the output?
body: <p>I have a requirement to execute some commands on remote machine and i have written script like this on my local machine. <br></p>
  
  <p>Basically i'm getting <code>docker images</code> on my local machine and want to check whether those images are existing in remote server or not. <br></p>
  
  <p>I need to get non existing docker images (remote server) to my local machine. For that i have used below mentioned code, but it didn't work for me.</p>
  
  <pre><code>#!/bin/sh
  declare array=$(docker images)
  sshpass -p 'password' ssh -t username@1.2.3.4 &lt;&lt; EOF
  declare List=""
  while read -r line; do
    if [ -z $(docker images -q $line) ]; then
      List="$List $line"
    else
      continue
    fi
  done &lt;&lt;&lt; "$array"
  EOF
  </code></pre>
  
  <p>I want List variable to be in my local machine.</p>
  
  <p>Can anyone help me on this issue?<br>
  Your help is much appreciated.<br>
  Best Regards.</p>