title: ssh to remote server gives incorrect hostname
body: <p>Below piece of code is part of my build script &amp; I'm running it from Jenkins as a parameterized build option(node).</p>
  
  <p>It is able to connect to server_b and does the tasks as expected, but the only command not working is the "hostname -f".</p>
  
  <p>It still gives the server_a's hostname value instead of server_b's hostname value.</p>
  
  <p>I'm not sure what exactly I'm doing incorrectly,thanks.</p>
  
  <pre><code>#!/bin/bash
  
  server_b(){
  
   folder="/home/mylogin/server_b"
   ssh -tt myuser@server_b.com &lt;&lt; EOF
    echo "$(hostname -f)" ## tried echo `hostname -f` as well
    cd $folder 
    echo -e "FOLDER: $folder"
    &lt;other commands that works fine&gt;
    exit 
  EOF
  }
  
  
  server_b
  </code></pre>