<div>#!/bin/bash</div><div><br></div><div>H="<br>192.168.1.1</div><div>192.168.1.2</div><div>192.168.1.3</div><div>192.168.1.4</div><div>"</div><div><br></div><div>for i in $H ; do</div><div><div> expect << -EOF-</div><div>set timeout 2</div><div>spawn scp ${rootidfile} root@${host}:/tmp/id_file</div><div>expect "d:"</div><div>send "${password}\n"</div><div>expect eof</div><div>spawn ssh ${host}</div><div>expect "d:"</div><div>send "${password}\n"</div><div>expect "#"</div><div>send "mkdir -p /root/.ssh; chmod 700 /root/.ssh\n"</div><div>expect "#"</div><div>send "cat /tmp/id_file >> /root/.ssh/authorized_keys\n"</div><div>expect "#"</div><div>send "rm -f /tmp/id_file; exit\n"</div><div>expect eof</div><div>-EOF-</div></div><div>done</div><div><br></div><div><br></div><div><a href="http://www.bsdmap.com/2010/11/06/ssh-shell-script/">http://www.bsdmap.com/2010/11/06/ssh-shell-script/</a></div><div><includetail><div> </div><div> </div><div style="font:Verdana normal 14px;color:#000;"><div style="FONT-SIZE: 12px;FONT-FAMILY: Arial Narrow;padding:2px 0 2px 0;">------------------ Original ------------------</div><div style="FONT-SIZE: 12px;background:#efefef;padding:8px;"><div id="menu_sender"><b>From: </b> "Kill Script"<killscript@gmail.com>;</div><div><b>Date: </b> Tue, Nov 16, 2010 02:47 AM</div><div><b>To: </b> "centos"<centos@centos.org>; <wbr></div><div></div><div><b>Subject: </b> [CentOS] good shell script examples?</div></div><div> </div>I am looking for a beginner guide to shell scripting simple tasks on CentOS (e.g. ssh'ing into a server / router / switch, checking for certain things, then exiting and going to the next IP).<div><br></div><div>Does anyone have any suggestions on where to look? ?(I'm relatively new to bash)</div>
</div></includetail></div>