[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[OT] ssh login script - Please Help
- From: Dan Track <dan track gmail com>
- To: "Community assistance, encouragement, and advice for using Fedora." <fedora-list redhat com>
- Subject: [OT] ssh login script - Please Help
- Date: Thu, 7 May 2009 15:22:03 +0100
Hi
I appreciate this is OT but could someone just give me a little
advice, I've written this script to logon on each server then restart
the ntpd daemon. The problem I have is it only restarts the daemon for
the last server provided in the list, any ideas as to why and how to
fix it?
#!/usr/bin/expect -f
set argc [llength $argv]
for {set i 0} {$i<$argc} {incr i} {
puts "arg $i: [lindex $argv $i]"
set var1 [lindex $argv $i]
spawn scp /etc/ntp.conf "root $var1:/etc/"
spawn ssh root $var1 "/etc/init.d/ntpd restart"
}
#######################
expect {
-re ".*es.*o.*" {
exp_send "yes\r"
exp_continue
}
-re ".*sword.*" {
exp_send "<password>\r"
}
}
interact
When run I get the following:
./test.expect server1 server2
arg 0: server1
spawn scp /etc/ntp.conf root server1:/tmp/
spawn ssh root server1 /etc/init.d/ntpd restart
arg 1: server2
spawn scp /etc/ntp.conf root server2:/tmp/
spawn ssh root server2 /etc/init.d/ntpd restart
root server2's password:
Shutting down ntpd: [ OK ]
Starting ntpd: [ OK ]
Any ideas?
Thanks for any help.
Dan
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]