I have a script in AIX to read all hosts from os_init.d directory and gather their Ipv4 IPs and store them in a file.This file is then used to ssh to each host to collect various data via other scripts [not relevant here].When the host is not reachable and has IPv4 IP address --> no error, while loop continuesWhen the host is not reachable and has IPv6 IP address --> no error, while loop continuesWhen the host is reachable and has IPv6 IP address --> while loop continues BUT exists without going through the loop.I can't seem to figure out why in the last condition, after successfully executing the if condition for a reachable IPv6 host, the while loop would exit without continuation. #!/usr/bin/bash# Sumit Das 2016 12 26# Find All PHYsical HOSTs and their IP in a cluster#set -x#cd /home/users/in10c2/monils -1 /cAppCom/os_init.d | grep dcpaix > listPHYSERVFN='listPHYSERV'rm listPHYIP 2> /dev/nullwhile read LINEdo  PHYHOST=$LINE  PHYHOSTIP=`ping -c 1 $LINE | grep PING | awk '{print $3}' | cut -c2- | rev | cut -c3- | rev`  IPV6IPchk=`echo $PHYHOSTIP | cut -c -4`  if [ $IPV6IPchk = 2a00 ]     then     ssh -q -o ConnectTimeout=10 -o BatchMode=yes -o StrictHostKeyChecking=no $LINE ifconfig -a > IFCNF     PHYHOSTIP=`awk '/en2:/{x=NR+1;next}(NR<=x){print}' IFCNF | awk '{print $2}'`     rm IFCNF  fi  echo $PHYHOST,$PHYHOSTIP >> listPHYIPdone < $FNcat listPHYIPcp  ALL_PHY_HOSTIP_`uname -n`.txt
if condition with ssh exits while loop without completion
shell script;ssh
You need to use ssh -n, otherwise a successful ssh consumes standard input and your while loop is left with nothing to read.