linux主機dns偵測

#!/bin/bashbash


ip_list=${1:?'please the ip list!'}
sum=$(cat $1 | wc -l )
j=1ssh

#recycle
for i in `cat $1`
do
ip=$(echo "$i"|cut -f1 -d":")
password=$(echo "$i"|cut -f2 -d":")
echo "##########process percent:"$j"/"$sum"##########"
let j=j+1ide

dns_info=$(expect -c"
set timeout 1
spawn ssh  root@$ip \"cat /etc/resolv.conf | grep nameserver\"
        expect {
                \"*yes/no*\" {send \"yes\r\"; exp_continue}
                \"*yes/no*\" {send \"yes\r\"; exp_continue}
                \"*password*\" {send \"$password\r\"; exp_continue}
                \"*Password*\" {send \"$password\r\"}
               }
")spa

dns_log=$(echo  "$dns_info" | grep nameserver | sed /spawn/d)server

#print
echo -e "$ip\n$dns_log"dns

#record into a file
cat << eof >>dns_info.log
host $ip
$dns_log
***************************
eofip

doneget

相關文章
相關標籤/搜索