#!/bin/bash
Auto_Ssh()
{
/usr/bin/expect <<EOF
spawn ssh root@$1 hostname
expect {
"yes/no" { send "yes\r" ;exp_continue }
"password" { send "Asimov\r" }
}
expect eof
EOF
}
for IP in {1..10}
do
ping -c1 -w1 172.25.254.$IP &> /dev/null
if [ "$?" -eq "0" ]
then
echo "`Auto_Ssh 172.25.254.$IP |tail -n 1 |sed 's/^M//g'` A 172.25.254.$IP" >> /mnt/host
fi
done