#!/bin/bash
H="
192.168.1.1
192.168.1.1
192.168.1.2
192.168.1.3
192.168.1.4
"
for i in $H ; do
expect << -EOF-
set timeout 2
spawn scp ${rootidfile} root@${host}:/tmp/id_file
expect "d:"
send "${password}\n"
expect eof
spawn ssh ${host}
expect "d:"
send "${password}\n"
expect "#"
send "mkdir -p /root/.ssh; chmod 700 /root/.ssh\n"
expect "#"
send "cat /tmp/id_file >> /root/.ssh/authorized_keys\n"
expect "#"
send "rm -f /tmp/id_file; exit\n"
expect eof
-EOF-
done
------------------ Original ------------------
Date: Tue, Nov 16, 2010 02:47 AM
To: "centos"<centos@xxxxxxxxxx>;
Subject: [CentOS] good shell script examples?
Does anyone have any suggestions on where to look? ?(I'm relatively new to bash)
_______________________________________________ CentOS mailing list CentOS@xxxxxxxxxx http://lists.centos.org/mailman/listinfo/centos