I am trying to change the "hostname --transient" to some computers with a for loop using a variable. I want it to collect the "hostname -f" from the server itself and, using the variable, change it automatically. When I run it, it tells me "Invalid number of arguments."
Command:
for i in `cat /tmp/serverlist`; do echo "Hostname in $i" ssh -o StrictHostKeyChecking=no root@$i "hostname=$(hostname -f); hostnamectl --transient set-hostname $hostname" done