Using pssh to replace text in place

144 views Asked by At

Anyone here used pssh to modify files in place, I've tried attempts like so;

while read line; 
do 
pssh --inline-stdout -H "$line" "hostname;
sudo sed -i \'s/search domain123.local/search domain123.local domain456.local/g\' /etc/resolv.conf;
sleep 1"; 
done < <(cat listOfIPs.txt)

Although pssh returns Success status, it doesn't amend resolv.conf on the actual host - am I missing something obvious in the pssh or sed command?

Thanks!

1

There are 1 answers

0
CiCa On

I found by altering the quotes, from single to double in the sed part, it seemed to fix it:

while read line; 
do 
pssh --inline-stdout -H "$line" "hostname;
sudo sed -i \"s/search domain123.local/search domain123.local domain456.local/\" /etc/resolv.conf;"; 
done < <(cat listOfIPs.txt)

And I also removed the /g but I don't think that really made a diff