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:
[bash]
host ServerName | sed -rne 's/.*has address ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/\1/p' | head -n 1
[/bash]
Note: Syntax error was picked up by freespace
Friday, February 20, 2009
Monday, February 9, 2009
Handy wordpress plugin
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:
[python]
def main():
print "This is python^^"
if __name__ == "__main__":
main()
[/python]
It also adds a few nice buttons. Here is an example:
[python]
def main():
print "This is python^^"
if __name__ == "__main__":
main()
[/python]
Subscribe to:
Posts (Atom)