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


Good idea! | 21 comments | Create New Account
Click here to return to the 'Good idea!' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
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 | # ]