Perl ‘getent hosts’ equivalent for MacOSX
We have a number of Mac users, and from time to time, they’ll play with /etc/hosts for some website testing, then forget that they had made such a change. Weeks later they’ll wonder why www.work.org is showing the contents, of, say qa.work.org.
For Linux users I’m used to asking for the output of ‘getent hosts www.work.org’. For Mac users, I’ll now ask for
perl -mSocket -e 'print Socket::inet_ntoa(scalar gethostbyname("www.aarp.org")), "\n"'
It works, but doesn't lend itself to troubleshooting over the phone.
Leave a Comment