#!/bin/bashfile=app.txtnum=`cat $file |wc -l`j=1 while (( j <= $num )) do ip=`awk -v k=$j '{if(NR==k)print $2}' $file` name=`awk -v k=$j '{if(NR==k)print $1}' $file` #echo $ip $name sshpass -p "" ssh -o StrictHostKeyChecking=no hjt@$ip "/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print \$2}' | tr -d 'addr:' " if [ $? -ne 0 ] then echo -e '\e[0;41m ERROR \e[0m' echo $name >> log.cmd.txt echo $ip >> log.cmd.txt else echo -e '\e[0;32m OK! \e[0m' fi ((j+=1)) done