Re: good shell script examples?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



#!/bin/bash

H="
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


http://www.bsdmap.com/2010/11/06/ssh-shell-script/
 
 
------------------ Original ------------------
Date:  Tue, Nov 16, 2010 02:47 AM
To:  "centos"<centos@xxxxxxxxxx>;
Subject:  [CentOS] good shell script examples?
 
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).

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

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux