Why is it that no matter how long I put the sleep command or loop, cat is unable to read the file, even though
the file already exsists? Is there any way of reliably waiting for the whois to finish, write to file and then read that the file exsists?? Could this have anything to do with using network mapped diretories or using cygwin?
whoisDoc=`whois -H "$query" > "/cygdrive/location/whois$query"`
netName=" "
orgName=" "
Country=" "
#Wait for whois to be written to disk
escape=0
cat whois$query > /dev/null
timer=$?
while [ $timer -ne 0 ];do
sleep 5
escape=$((escape+1))
if [ $escape -gt 100 ];then
break
fi
cat whois$query
timer=$?
done
#add whois to array
netName=$(cat whois$query | grep -i 'netname'| gawk '{print $2}')
orgName=$(cat whois$query | grep -i 'orgname'| gawk '{print $2}')
Country=$(cat whois$query | grep -i 'Country'|gawk '{print $2}')
echo $Country","$orgName","$netName > /dev/tty
Here is the Error that repeats with the loop.
cat: whoisfile: No such file or directory