I am trying to write a script to login to several remote servers and execute a script in each server. However, I'd like to pass a variable through ssh. Something like this:
var="/home/dir/"
  ssh -T $mchname <<'ENDSSH'    
    $var"run_script" < input > output &    
ENDSSH
This naive try does not work ($var is simply null). What would be the correct syntax? Thanks in advance.
Remove the quotes from around ENDSSH. They prevent expansion of variables within the here document.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With