title: How to run commands on remote machine using bash script?
body: <p>I am trying to run the below commands on remote machine, but nothing is being getting executed, Can anyone point out the issue with the below script?</p>
  
  <p>FYI settings.yml and fuscation_util.rb files are present in the <code>testuser</code> account</p>
  
  <p><strong>SCRIPT:</strong></p>
  
  <pre><code>sshpass -p "PASSWORD" ssh -o StrictHostKeyChecking=no -T root@HOSTNAME &lt;&lt;EOF
      su - testuser
      NEWLINE=$'\n'
      read -s -p "Enter Presto Password:${NEWLINE}" VD_PASSWORD
      KEY=`cat settings.yml |grep '^key:'|sed 's/^key: //'`
      VALUE=`ruby fuscation_util.rb encrypt  "$KEY" "$VD_PASSWORD"`
      echo "$VALUE"
  EOF
  </code></pre>
  
  <p><strong>OUTPUT:</strong></p>
  
  <pre><code>cat: settings.yml: No such file or directory
  ruby: No such file or directory -- fuscation_util.rb (LoadError)
  </code></pre>
  
  <p>I am facing the error only when I try to assign the poutput to some variable, with the below script I didnt get any errors</p>
  
  <p><strong>SCRIPT:</strong></p>
  
  <pre><code>sshpass -p "PASSWORD" ssh -o StrictHostKeyChecking=no -T root@HOSTNAME &lt;&lt;EOF
      su - testuser
      NEWLINE=$'\n'
      read -s -p "Enter Presto Password:${NEWLINE}" VD_PASSWORD
      cat settings.yml |grep '^key:'|sed 's/^key: //'
      ruby fuscation_util.rb encrypt  "testvalue" "testpassword"
  EOF
  </code></pre>
  
  <p><strong>OUTPUT:</strong></p>
  
  <pre><code>WORKING FINE
  </code></pre>