0

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

Edited by duke.tim

2
Contributors
2
Replies
27
Views
4 Years
Discussion Span
Last Post by duke.tim
0

Doh!

Thanks for the help, maybe it is time for me to take a breather from coding.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.