I'm trying to write a shell script using bash that connects to a remote server, runs a command that generates a file, pulls the file over, then renames it with the hostname of the remote server and a an extension.
So far, I'm able to everything but pull the hostname of the remote server into a variable.
REMHOST='ssh root@192.168.1.1 hostname'
echo $REMHOST
returns:
ssh root@192.168.1.1 hostname
When I run the command from the prompt, it returns what I am looking for. I also tried:
REMHOST='ssh root@192.168.1.1 hostname 2>$1'
echo $REMHOST
and i had similar results, where the contents of the ' were returned.
Thanks in advance for the help