Comments (8)
  • Add a Comment
  • Edit
  • More Actions v
  • Quarantine this Entry

1 MarkChandler commented Permalink

I really like this command because it'd make it easy to script host file maintenance. Using the echo method wouldn't get you the return codes you need. So, you'd have to combine it with some ugly grep for sanity checking. However, I like ordering my host files by IP, so I'm interested to know what hostent does with new entries. <div>&nbsp;</div> Nice find, Anthony!

2 AnthonyEnglish commented Permalink

If you have to add an IP address on multiple hosts, you could run dsh hostent from one host and update the lot of them with a single command.

3 Wallace_Lam commented Permalink

I wish that there are other commands similar to "hostent" like inetdent, inittabent, sshdent, etc.

4 AnthonyEnglish commented Permalink

You're right, Wallace, although there are a few commands which deal with some of those files. <div>&nbsp;</div> There is the chitab command which allows you to change entries in /etc/inittab, but not comment them out. Also rmitab to remove them. Also, the namerslv lets you edit /etc/resolv.conf. What about /etc/services, or /etc/inetd.conf? <div>&nbsp;</div> It would be interesting to look at some of the AIX command documentation (http://bit.ly/keL5gn) to see what sort of commands are available to let you change those sort of configuration files without directly editing the file. Maybe it would be a good article for developerWorks.

5 banicek commented Permalink

but you can easily get in problem if you use echo "192.168.2.5 mynewhost" &gt; /etc/hosts instead of echo "192.168.2.5 mynewhost" &gt;&gt; /etc/hosts ...:)

6 AnthonyEnglish commented Permalink

Good observation. Overwrite with &gt; or append with &gt;&gt; is the difference between an extra person hopping on a train or pushing everyone else off the train first, including the driver. <div>&nbsp;</div> I once saw /etc/passwd wiped out by someone who was trying to print it and accidentally overwrote it with that single redirection &gt; <div>&nbsp;</div> Most of us edit files, but if you're getting someone new on the job, or have to script the change, I say let him use SMIT if he can, or commands such as hostent, until he is confident and competent with an editor.

7 ariakerry222 commented Permalink

It would be interesting to look at some of the AIX command documentation (http://bit.ly/keL5gn) to see what sort of commands are available to let you change those sort of configuration files without directly editing the file. Maybe it would be a good article for developerWorks. <a rel="follow" href="http://www.thesiswritinghelp.co.uk/">Thesis</a>

8 AnthonyEnglish commented Permalink

Good point. <div>&nbsp;</div> This IBM developerWorks article "Safer Than Editing" is a start. http://goo.gl/DFDnw but there are many more commands which are worth investigating. <div>&nbsp;</div> Thanks for your suggestion and for following this blog.