I'm having some difficulties to find a solution to my problem. I have passed over 2 days in internet to find something, but nothing is working. Maybe it's simply not possible, but before giving up I would like to ask here. Thanks in advance,
The aim of this script is to ask to an admin on the local machine the IP address of the remote machine that will be configured, stock the IP in a variable and then automatically connect via ssh and execute the script that will change the hostname of the remote machine. I know that the way I m trying to do cannot work because the variable are not are not send over ssh.
Do you have idea about how I can do this ? I insist that I really want to do it in that way, because I know there is some more easier way to do but I want to solve it in the form for my own knowleadge purpose.
You seem to have a problem with spaces in your listing yielding a code full of errors.
If all those corrected, use a "here document" for the remote commands. Like
Be aware of the escaped $ - chars for the variable expansion - without those, expansion would be done by the local shell, not the one on the remote node.
Thanks a lot for your reply see bellow normally the script doesn't looks like this I don't know why when I posted on this page the spaces disappeared.
I'm sorry I'm not that good in scripting still learning.
Can you explain me why you have added the variable with "\" ( \$) , is it the way to explain to the terminal that those variables needs to be executed on the remote shell ?
You are in a dilemma here: you want the IP variable expanded locally, but the other variables expanded remotely. For the first, you can't have the "word" quoted, but it must be unquoted, so, for the second, you need to apply the escapes for the $ signs.