Script to determine which web server at ip addresses

how do we determine if ip addresses are hosting IIS version 7.x or Apache 2.2.x. ?

nmap -p 80 -sV $IP 

Thanks . sorry did not really understand do you mind explaining? and how do we print which ip is iis and which one is apache?

The output of nmap is fairly self explanatory, substitute the actual IPs for $IP in the above, or look up the nmap manual at insecure.org.