Iterate-hosts

Aus Labor für Echtzeitsysteme

Wechseln zu: Navigation, Suche
#!/usr/bin/env python
#
# usage: iterate-hosts.py <filename>
#
 
import sys
import os
 
file = sys.argv[1]
fd = open( file ) # john style syntax: password (user)
 
lines = fd.readlines( )
fd.close( )
 
for i in range( 1, 33 ):
 
# eigenen Host ueberspringen
if i == 21:
continue
 
 
for line in lines:
splitted = line.strip( '\n' ).split( ' ' )
splitted[1] = splitted[1][1:-1]
 
print "xterm -e /home/clemens/cipher/ssh-remote-login.sh %s@10.1.%s.3 %s &" % (splitted[1], i, splitted[0])
os.system( "xterm -e /home/clemens/cipher/ssh-remote-login.sh %s@10.1.%s.3 %s &" % (splitted[1], i, splitted[0]) )
#!/usr/bin/env expect
#
# usage: ssh-remote-login.sh <user>@<host> <password>
#
 
set host [lindex $argv 0]
set pw [lindex $argv 1]
 
set timeout 30
spawn ssh $host
expect {
"assword:" {
send "$pw\r"
} "yes/no)?" {
send "yes\r"
set timeout -1
} timeout {
exit
} eof {
exit
}
}
 
expect {
"assword:" { exit }
"$ " {interact}
}
Persönliche Werkzeuge