0

I have n number of servers like:

c0001234.cloud.com
c0005678.cloud.com
c0009123.cloud.com

I need to write one script that will login to these servers and edit one file. Basically there is one variable in that file and I have to replace that value. Successfully able to login to the servers but but able to edit the file. How can I write the script that will edit the file on all the servers. FileName and Variable name is same on all the servers.

string2=c0001234.cloud.com,c0005678.cloud.com,c0009123.cloud.com
for j in $(echo $string2 | sed "s/,/ /g")
do
    ssh -o StrictHostKeyChecking=no -tt -q AppAccount}@$j stty < /dev/null
    ????????????????????????
done

1 Answer 1

1

What is the purpose of stty < /dev/null?

First, don't use comma as separator, use space, it simplifies the loop later.

string2="c0001234.cloud.com c0005678.cloud.com c0009123.cloud.com"
for j in $string2; do
    ssh -o StrictHostKeyChecking=no AppAccount@$j sed -i -e 's/var/value/g' file
done

This will replace var with value in file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .