Month: February 2009

Handy bash one liner for getting the ip address of a host

Posted by on February 19, 2009

Something I find that I have to do in bash scripts occasionally is to grab the ip address of a specific computer. This requires a little parsing in most cases (due to cnames and multiple ipv4 addresses for a host).

The following one liner should handle all of this correctly:

host ServerName | sed -rne 's/.*has address ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/\1/p' | head -n 1

Note: Syntax error was picked up by freespace

Handy wordpress plugin

Posted by on February 9, 2009

This is just a really quick post to mention that I have found (well, actually Mat found it) a nice plugin for wordpress to support dumping source code into entires. This pluging is called syntaxhilighter-plus. It allows you to easily drop source code into a page.

It also adds a few nice buttons. Here is an example:

def main():
  print "This is python^^"

if __name__ == "__main__":
  main()