I would use tcping too, if it were available on these other systems I expect my scripts to run on.
Thanks for spotting my dumb mistake in the parsing.
Are you sure nmap is on all these systems? It quite often isn't (not a default package anyway) for security reasons (no need to make scanning the network any easier) ...
If you need to install nmap you might as well install tcping at the same time ;)
This is where tools like puppet become rapidly useful of course...