jaysilverheels
asked on
script to add new line to file in multiple servers with ssh
This script below only works if there is one hostname in the hosts field at the start. Not sure if the appending is the best way either. Also have to sudo to root
#!/usr/bin/ksh
ADD="goodbye"
file="/tmp/bucket"
hosts="host1-1,host-2"
for i in ${hosts} do
ssh ${i} ; sudo su -
"echo $ADD >> $file"
done
#!/usr/bin/ksh
ADD="goodbye"
file="/tmp/bucket"
hosts="host1-1,host-2"
for i in ${hosts} do
ssh ${i} ; sudo su -
"echo $ADD >> $file"
done
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Are you able to change the sudo setup on the remote servers?
If not, then your script will need to be more complicated.
If not, then your script will need to be more complicated.
ASKER
")
ASKER