<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Claus Witt &#187; easy creation</title>
	<atom:link href="http://www.clauswitt.com/tag/easy-creation/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.clauswitt.com</link>
	<description>software and web developer</description>
	<lastBuildDate>Thu, 24 Jun 2010 20:07:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Bash script for editing the hosts file</title>
		<link>http://www.clauswitt.com/319/</link>
		<comments>http://www.clauswitt.com/319/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 09:02:46 +0000</pubDate>
		<dc:creator>Claus Witt</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[easy creation]]></category>
		<category><![CDATA[hosts]]></category>
		<category><![CDATA[shell script]]></category>

		<guid isPermaLink="false">http://www.clauswitt.com/?p=319</guid>
		<description><![CDATA[I just read a post about local development in apache by Jesper Rasmussen and thought one thing was missing. I usually test my sites and applications locally with the real domain &#8211; to ensure that functionality based on the url works as expected. However this means editing the hosts file several times a day. Now [...]]]></description>
			<content:encoded><![CDATA[<p>I just read a <a href="http://jesperrasmussen.com/coding-on-the-go-setting-up-local-apache">post about local development in apache</a> by <a href="http://jesperrasmussen.com/">Jesper Rasmussen</a> and thought one thing was missing. I usually test my sites and applications locally with the real domain &#8211; to ensure that functionality based on the url works as expected. However this means editing the hosts file several times a day. Now I have made a small shellscript that will add and remove lines from the hosts file. </p>
<pre name="code" class="bash">
#! /bin/bash
DEFAULT_IP=127.0.0.1
IP=${3:-$DEFAULT_IP}

case "$1" in
  add)
        echo "$IP $2"  >> /etc/hosts
        ;;
  remove)
        sed -ie "\|^$IP $2\$|d" /etc/hosts
        ;;

  *)
        echo "Usage: "
		echo "hosts.sh [add|remove] [hostname] [ip]"
		echo
		echo "Ip defaults to 127.0.0.1"
		echo "Examples:"
		echo "hosts.sh add testing.com"
		echo "hosts.sh remove testing.com 192.168.1.1"
        exit 1
        ;;
esac

exit 0
</pre>
<p>As you can see the script defaults the ip to 127.0.0.1 for easy creation of local domains. Next step is to create a quicksilver (and a gnome do) plugin for easy creation without ever touching the terminal. (Even though we all love the terminal, right?) </p>
]]></content:encoded>
			<wfw:commentRss>http://www.clauswitt.com/319/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
