Below is one of the part of my script, but I am struggling to get the solution. I am using pssh command along with awk to filter particular column from user input OS command. awk with pssh command only having an issue when sudo to any user.
Below Provide me correct input.
pssh -h /tmp/hosts -i 'echo $(echo ), $(uptime|awk '\''{print $3}'\'')'
[1] 13:15:40 [SUCCESS] Host1
, 75
[2] 13:15:40 [SUCCESS] Host2
, 59
[3] 13:15:40 [SUCCESS] Host3
, 147
But below provide me incorrect input (gives output of uname -a) when sudo to quser.
sudo -i -u quser pssh -h /tmp/hosts -i 'echo $(echo ), $(uptime|awk '\''{print $3}'\'')'
[1] 13:16:11 [SUCCESS] host1
, 13:16pm up 147 days 4:48, 1 user, load average: 0.02, 0.05, 0.01
[2] 13:16:11 [SUCCESS] host2
, 13:16pm up 59 days 3:04, 0 users, load average: 0.52, 0.29, 0.22
[3] 13:16:11 [SUCCESS] host3
, 13:16pm up 75 days 3:38, 0 users, load average: 0.03, 0.02, 0.00