title: Passing a variable to a remote host in a bash script with ssh and EOF
body: <p>I have a script parsing a list of servers, looking for some stuff and executing commands if the circumstances are correct.
  The main server is connecting to them via ssh, executing all commands that are in the EOF statement:</p>
  
  <pre><code>#!/bin/bash
  
  # parsing servers
  # defining one local variable $VAR
  
  ssh -T -p 1234 root@"server-ip" "$variable" &lt;&lt; 'EOF'
  # doing some stuff...
  var_result=$(mysql -hhost -uuser '-ppasswort' -Ddatabase -N -e "SELECT something FROM somewhere WHERE value=$VAR;")
  EOF
  </code></pre>
  
  <p>I know the variable can pass through if I remove the single quotes from the EOF, but if i do so the mysql statements wont work and everything breaks.</p>
  
  <p>I know there are ways to transmit a variable, but things with ";" between options wont work for me ( the script tries to execute it as a command )</p>
  
  <p>Any ideas?</p>