I have the following script which sets the hostname for a remote host.
#!/bin/bash
ssh -T user@$1 << \EOF1
sudo sh -c "echo "hostname=\"$1\"" >> /etc/rc.conf"
sudo /etc/rc.d/hostname start
EOF1
When I run ./filename.sh host, the hostname isn't populated. How do I pass a variable to remote execution commands?
\EOFcauses$1to not be expanded in the here-doc. Is that what you wanted to do?