[yunwei@Y24-209 ~]$cat ls.sh #!/bin/bash ip55=`cat ip1` for i in $ip55;do ping -c 1 $i if [ $? -eq 0 ];then ssh -t $i "ls" if [ $? -eq 0 ];then echo -e "$i" >> ok.ip else echo -e "$i" >> fail.ip fi else echo -e "$i" >> fail.ip fi done