This is the final post of a thread documenting a request to update the resolv.conf file on 48 Linux servers that I am in charge of. Keep in mind that as of right now I do not have an Admin server that I can run scripts from that have SSH keys to login without password. Here’s is the working script that successfully patched the resolv.conf file on 48 servers.
Again here’s the starter script.
for i in `cat hosts.txt`
And here is the expect script.
|#!/usr/bin/expect -fset password password
set hosts [lrange $argv 0 0]
set timeout 05
spawn ssh my_login$hosts
send — “$password\r”
send “echo \search our.domain.info\ > /etc/resolve.conf\r”
send “echo \nameserver 126.96.36.199\ >> /etc/resolve.conf\r”
send “echo \nameserver 188.8.131.52\ >> /etc/resolve.conf\r”
so, Basically I fixed the timeout issue, so itdoes timeout after 5 seconds and forces the next send command. Also, I decided to run script as myself and sesu to root, so the root password is not in a clear text script, and we have two root passwords on random servers.