0

On my CentOS 7 machine, I am running this command:

pssh -h rephosts -i "/bin/getent hosts sync.$(hostname) | awk '{ print $1 }'"

but I am only getting my host ip (where i am executing this command) response from all servers.

I have added entries for hosts in my /etc/hosts file in all machines.

I want all the servers to respond with their ip address respectively.

0

$(hostname) is evaluated on your local host, before the pssh command is started. You can solve this by escaping the $:

pssh -h rephosts -i "/bin/getent hosts sync.\$(hostname) | awk '{ print \$1 }'"
| improve this answer | |
  • yes, thanks for the answer. Also I have to put another \ after the print \$1. – Ted Khi Dec 7 '18 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.