Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


lookupd | 21 comments | Create New Account
Click here to return to the 'lookupd' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
lookupd
Authored by: mchadwick on Nov 15, '05 07:10:08AM
Tiger uses lookupd to cache lookups. That means if you hit the ad before editing /etc/hosts and haven't logged out or restarted, chances are the ip is cached. This can be solved by running:
lookupd -flushcache
I make a habit of doing so after each edit of the hosts file, that way I remember, and since I edit the hosts file regularly I created a script called vihosts (named after visudo). I put it in ~/bin, which is in my $PATH. It's very simple:
#!/bin/sh
sudo vi /etc/hosts
lookupd -flushcache
You can replace vi with nano or whatever your favorite editor is. Just make sure it's in your path and executable and you can type vihosts to edit your hosts file now.

[ Reply to This | # ]
Good idea!
Authored by: zs on Nov 16, '05 08:08:37PM
Though I like to use the $EDITOR environment variable and full paths to make my scripts a little more robust, like so:
if [ $EDITOR ]; then
  /usr/bin/sudo $EDITOR /etc/hosts
else
  /usr/bin/sudo /usr/bin/vi /etc/hosts
fi
/usr/sbin/lookupd -flushcache

---
zs

[ Reply to This | # ]

Whoops...
Authored by: zs on Nov 16, '05 08:16:31PM
Don't forget the
#!/bin/sh
at the top of the script...

---
zs

[ Reply to This | # ]

Good idea!
Authored by: zs on Nov 17, '05 10:52:14AM
Looking back on this, it could be simplified further:
#!/bin/sh
if [ ! $EDITOR ]; then EDITOR=/usr/bin/vi; fi
/usr/bin/sudo $EDITOR /etc/hosts
/usr/sbin/lookupd -flushcache

---
zs

[ Reply to This | # ]