title: How to pass local variable to remote using ssh and bash script?
body: <pre><code>ssh remotecluster 'bash -s' &lt;&lt; EOF
  &gt; export TEST="sdfsd"
  &gt; echo $TEST
  &gt; EOF
  </code></pre>
  
  <p>This prints nothing.</p>
  
  <p>Also it still does not work even if I store the variable into file and copy it to remote.</p>
  
  <pre><code>TEST="sdfsdf"
  echo $TEST &gt; temp.par
  scp temp.par remotecluster
  ssh remotecluster 'bash -s' &lt;&lt; EOF
  &gt; export test2=`cat temp.par`
  &gt; echo $test2
  &gt; EOF
  </code></pre>
  
  <p>Still prints nothing. </p>
  
  <p>So my question is how to pass local variable to the remote machine as a variable ?</p>
  
  <p>Answers have been give in <a href="https://stackoverflow.com/questions/15775911/how-to-properly-escaping-qsub-command-with-long-input-args-within-ssh-command#15776073">this</a></p>