Skip to content
Tags

,

Perl ‘getent hosts’ equivalent for MacOSX

by pburkholder on January 22, 2011

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

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Bad Behavior has blocked 129 access attempts in the last 7 days.