<?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>Coderholic &#187; linux</title>
	<atom:link href="http://www.coderholic.com/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.coderholic.com</link>
	<description>Addicted to Development</description>
	<lastBuildDate>Tue, 31 Aug 2010 09:19:27 +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>PyWebShot &#8211; Generate website thumbnails using Python</title>
		<link>http://www.coderholic.com/pywebshot-generate-website-thumbnails-using-python/</link>
		<comments>http://www.coderholic.com/pywebshot-generate-website-thumbnails-using-python/#comments</comments>
		<pubDate>Sun, 11 Apr 2010 17:24:27 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[python gtkmozembed screenshot pywebshot webkit2png]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=643</guid>
		<description><![CDATA[There have been lots of links to automatic website thumbnail generators on sites like reddit and hacker news today, including webkit2png and CutyCapt. Well it just so happens that a few weeks ago I wrote my own website thumbnail generator, and today I got around to putting it on GitHub. The code is based on [...]]]></description>
			<content:encoded><![CDATA[<p>There have been lots of links to automatic website thumbnail generators on sites like reddit and hacker news today, including <a href="http://www.paulhammond.org/webkit2png/">webkit2png</a> and <a href="http://cutycapt.sourceforge.net/">CutyCapt</a>. Well it just so happens that a few weeks ago I wrote my own website thumbnail generator, and today I got around to putting it on <a href="http://github.com/coderholic/PyWebShot">GitHub</a>.</p>
<p>The code is based on Matt Biddulph&#8217;s <a href="http://burtonini.com/computing/screenshot-tng.py">screenshot-tng</a> script, but heavily modified to be more user friendly and provide more options. It uses embedded mozilla for rendering, and therefore requires the <a href="http://www.mozilla.org/unix/gtk-embedding.html">python-gtkmozembed</a> package.</p>
<p>You can specify a resolution to take the screenshot at, and also a resolution for the thumbnail. When generating the thumbnail the aspect ratio will be preserved. You can also specify a delay, so that the screenshot is only taken so many seconds after loading the page. Here&#8217;s an example of running PyWebShot with 3 URLs, and the resulting images:</p>
<pre>
$ ./pywebshot.py -t 500x250 http://www.coderholic.com http://geomium.com/update/598/ http://jobs.plasis.co.uk
Loading http://www.coderholic.com... saved as www.coderholic.com.png
Loading http://geomium.com/update/598/... saved as geomium.com.update.598..png
Loading http://jobs.plasis.co.uk... saved as jobs.plasis.co.uk.png
</pre>
<p><img src="http://www.coderholic.com/wp-content/uploads/coderholic.com_.png"/></p>
<p><img src="http://www.coderholic.com/wp-content/uploads/geomium.com_.update.598..png"/></p>
<p><img src="http://www.coderholic.com/wp-content/uploads/jobs.plasis.co_.uk_.png"/></p>
<p>It you have a huge list of URLs you&#8217;d like to generate screenshots for you can put them all into a file and generate images for them all with the following command:</p>
<pre>
$ cat urls.txt | xargs ./pywebshot.py
</pre>
<p>For more details and the source code see the <a href="http://github.com/coderholic/PyWebShot">PyWebShot project page</a> on GitHub.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/pywebshot-generate-website-thumbnails-using-python/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Server Monitoring with Munin</title>
		<link>http://www.coderholic.com/server-monitoring-with-munin/</link>
		<comments>http://www.coderholic.com/server-monitoring-with-munin/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 21:53:56 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[munin server opensource monitoring sysadmin]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=378</guid>
		<description><![CDATA[Munin is an excellent open source tool for monitoring and graphing server performance metrics. It can be configured to send out alert emails when something goes wrong with your server, and the graphs make it easy to view trends over time: You could see that your site gets much less traffic on a Sunday, for [...]]]></description>
			<content:encoded><![CDATA[<p>Munin is an excellent open source tool for monitoring and graphing server performance metrics. It can be configured to send out alert emails when something goes wrong with your server, and the graphs make it easy to view trends over time: You could see that your site gets much less traffic on a Sunday, for example, or that the number of database queries performed per day has doubled in the last 2 months.</p>
<p><img style="border: 1px solid gray;" src="/wp-content/uploads/munin-graphs1.png" alt="" /></p>
<p>On a Debian-based system installing Munin is as simple as running the following command, and then going to http://your-server/munin/ in your browser:</p>
<pre>sudo aptitude install munin</pre>
<p>Munin comes with lots of monitoring plugins by default, including those for MySQL, PostgresSQL, Apache, Tomcat, Squid, and for things such a CPU and memory usage, load average, network traffic, and many more. You can also find lots of user submitted plugins on sites like <a href="http://muninexchange.projects.linpro.no/">Munin Exchange</a>.</p>
<p>Munin doesn&#8217;t have to be used solely for monitoring server performance though. Being so easy to extend Munin is  also a great tool for tracking non-server performance related trends over time. In just a few lines of code you could write plugins to track the following stats about your website:</p>
<ul>
<li>Number of User signups</li>
<li>Google PageRank</li>
<li>Pages in Google&#8217;s index</li>
<li>Number of backlinks</li>
<li>Number of twitter mentions</li>
<li>Alexa traffic rank</li>
</ul>
<p>The <em>number of pages in Google&#8217;s index</em> is actually a plugin I&#8217;ve written. Simple put the following code in your /etc/munin/plugins directory to see it in action:</p>
<pre name="code" class="python">
#!/bin/sh
# Munin Plugin to display the number of pages in the
# google index for all of the given websites
# Ben Dowling - www.coderholic.com

# Change this to whatever sites you're interested in
websites="www.yahoo.com www.google.com www.twitter.com"

if [ "$1" = "autoconf" ]; then
        echo yes
        exit 0
fi

if [ "$1" = "config" ]; then

        echo 'graph_title Number of Pages in Google Index'
        echo 'graph_args --base 1000 -l 0 '
        echo 'graph_vlabel number of pages'
        echo 'graph_category google'
        echo 'graph_info This graph shows the number of pages in the Google index for a given website.'

        i=0
        for site in $websites
        do
                name="site_${i}"
                echo "${name}.label ${site}"
                echo "${name}.draw LINE2"
                echo "${name}.info The number of pages in the google index."
                i=$((i+1))
        done
        exit 0
fi

i=0
for site in $websites
do
        name="site_${i}"
		value=$(wget -q --user-agent=Firefox -O - "http://www.google.com/search?q=site:${site}" | grep -E "of about <b>[0-9,]+</b>" -o | grep -E "[0-9,]+" -o | sed "s/,//g")
        echo "${name}.value ${value}"

        i=$((i+1))
done
</pre>
<p>For more details about Munin see their <a href="http://munin.projects.linpro.no/">homepage</a>, which also includes detailed documentation on writing your own plugins. </p>
<p>Let me know if you can think of any more Munin plugins that could be interesting, or if you&#8217;ve used any yourself!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/server-monitoring-with-munin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>linewatch &#8211; an alternative to linux&#8217;s watch</title>
		<link>http://www.coderholic.com/linewatch-an-alternative-to-linuxs-watch/</link>
		<comments>http://www.coderholic.com/linewatch-an-alternative-to-linuxs-watch/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 20:11:23 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=290</guid>
		<description><![CDATA[I often use the linux watch command to monitor the status of certain commands. When I&#8217;m copying lots of files say, I&#8217;d watch the files in the target directory to see what files have already been copied across with the following command: watch ls -l The watch program clears the screen and displays the output [...]]]></description>
			<content:encoded><![CDATA[<p>I often use the linux <a href="http://linux.die.net/man/1/watch">watch</a> command to monitor the status of certain commands. When I&#8217;m copying lots of files say, I&#8217;d watch the files in the target directory to see what files have already been copied across with the following command:</p>
<pre>
watch ls -l
</pre>
<p>The watch program clears the screen and displays the output of &#8220;ls -l&#8221; every 2 seconds. </p>
<p>Sometimes I&#8217;ll want to monitor a command that only outputs a single line. If I wanted to see the total number of files in a directory rather than the files themselves I could use the command &#8220;ls -l | wc -l&#8221;. The fact that watch clears the whole screen can be a little annoying here though, because the command is only outputting a single line. That is why I came up with the following small bash script, linewatch. </p>
<p>Linewatch repeatedly calls any arguments passed to it every 2 seconds (in the same way watch does), but only clears a single line rather than the whole screen. Here is the code:</p>
<pre name="code" class="python">
#!/bin/bash
clearline="\b\033[2K\r"
command=$@

while true
do
    eval "$command"
    sleep 2
    echo -n -e "$clearline"
done
</pre>
<p>And here is an example of how to call it:</p>
<pre>
$ ./linewatch "ls -l | wc -l"
24
</pre>
<p>The number of files in the current directory (24 in the example) will keep update every 2 seconds. Just hit Ctrl-C when you want to quit,</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/linewatch-an-alternative-to-linuxs-watch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SVN Change Monitoring Script</title>
		<link>http://www.coderholic.com/svn-change-monitoring-script/</link>
		<comments>http://www.coderholic.com/svn-change-monitoring-script/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 19:56:00 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=280</guid>
		<description><![CDATA[I came up with the following shell script recently to monitor code changes in a subversion repository. On the first run it will emails out the 10 most recent changes. After that the script mails out all changes since the last time it was run. You can set it up to run as a daily [...]]]></description>
			<content:encoded><![CDATA[<p>I came up with the following shell script recently to monitor code changes in a subversion repository. On the first run it will emails out the 10 most recent changes. After that the script mails out all changes since the last time it was run. You can set it up to run as a daily cron job which mails you all changes made to you favourite open source project!</p>
<p>It wouldn&#8217;t take much to get it working with other version control systems such as Git or Bazaar, or to do some nice formatting of the output instead of outputting the raw svn log as-is. Let me know if you find it useful!</p>
<pre name="code" class="python">
#!/bin/bash
# Shell script to email the latest changes in an SVN
# repsitory to a specified email address.
# Ben Dowling - wwww.coderholic.com

svnUrl="http://anonsvn.wireshark.org/wireshark/trunk/"
lastRevisionFile="./.last-revision"
mailto="ben@coderholic.com"

function getCurrentRevision {
  # Get the current SVN revision, eg. "r4670"
  currentRevision=$(svn log "$svnUrl" -r HEAD 2&gt;/dev/null | head -n2 | grep -v -- "-------" | awk '{ print $1 }')
  # Strip off the 'r'
  currentRevision="${currentRevision:1}"
  echo "$currentRevision"
}

currentRevision=$(getCurrentRevision)

# If we've run this program before then we've stored the SVN revision at the time
if [ -f "$lastRevisionFile" ]
then
  lastRevision=$(cat "$lastRevisionFile")
  #  Check what the current revision is, and exit if there
  # haven't been any changes since we last checked
  if [ $currentRevision -lt $lastRevision ]
  then
      echo "No changes since last check"
      exit
  fi
else
  # We haven't run this program before, so set the last revision to the current revision - 10
  lastRevision=$(echo "$currentRevision - 10" | bc)
fi

# Mail the SVN changes
svn log "$svnUrl" -r "HEAD:${lastRevision}" | mail -s "SVN changes for $svnUrl" $mailto

# Store the current revision + 1 as the last revision
revision=$(echo "$currentRevision + 1" | bc)
echo "$revision" &gt; "$lastRevisionFile"
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/svn-change-monitoring-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Ultimate Scalability Presentation</title>
		<link>http://www.coderholic.com/the-ultimate-scalability-presentation/</link>
		<comments>http://www.coderholic.com/the-ultimate-scalability-presentation/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 19:37:54 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[software design]]></category>
		<category><![CDATA[web dev]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=231</guid>
		<description><![CDATA[At work we&#8217;re experiencing some fairly rapid growth, and our single production server is starting the feel the strain. I&#8217;ve been doing a lot of investigation into how we can scale the site, and thankfully there is lots of information out there. The &#8220;Do you Scale&#8221; presentation I saw at PHP London a couple of [...]]]></description>
			<content:encoded><![CDATA[<p>At <a href="http://www.mendeley.com">work</a> we&#8217;re experiencing some fairly rapid growth, and our single production server is starting the feel the strain. I&#8217;ve been doing a lot of investigation into how we can scale the site, and thankfully there is lots of information out there. </p>
<p>The &#8220;<a href="http://www.coderholic.com/php-london/">Do you  Scale</a>&#8221; presentation I saw at PHP London a couple of months ago gave a good high level overview of scalability issues, and included some useful techniques to help you scale.</p>
<p>I think I&#8217;ve found the ultimate scalability presentation though: &#8220;Real World Web: Performance &#038; Scalability&#8221;. The 189 slides contained within this presentation cover almost everything I&#8217;ve read elsewhere, and it&#8217;s packed full of practice advice!</p>
<p><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=rwwmysql2008-1216304757388368-8&#038;stripped_title=real-world-web-performance-scalability" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=rwwmysql2008-1216304757388368-8&#038;stripped_title=real-world-web-performance-scalability" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/the-ultimate-scalability-presentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Connection Killer</title>
		<link>http://www.coderholic.com/mysql-connection-killer/</link>
		<comments>http://www.coderholic.com/mysql-connection-killer/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 14:33:33 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=223</guid>
		<description><![CDATA[MySQL has a kill command which lets you kill a specific query or connection. This is useful it situations where you&#8217;ve accidentally issued a really complex query, or an application created a persistent connection and forgot to close it. Killing lots of connections can be tedious though. Say an application has created lots of persistent [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL has a <a href="http://dev.mysql.com/doc/refman/5.0/en/kill.html">kill</a> command which lets you kill a specific query or connection. This is useful it situations where you&#8217;ve accidentally issued a really complex query, or an application created a persistent connection and forgot to close it. </p>
<p>Killing lots of connections can be tedious though. Say an application has created lots of persistent connections and not closed any of them, you&#8217;d have to go through the following steps:</p>
<p><code><br />
mysql&gt; SHOW FULL PROCESSLIST; /* shows all connections */<br />
mysql&gt; KILL &lt;process_id&gt;; /* for EVERY process you want to kill */<br />
</code></p>
<p>To make this process much simpler I wrote a little bash script that will kill all connections for a given MySQL user.</p>
<pre name="code" class="python">
#!/bin/bash
# Kill all MySQL connections for a given user
# Ben Dowling - Apr 2009
# www.coderholic.com

user="root" # MySQL super user
pass="" # Above user's password
kill_user="myapp" # User who you want to kill all the connections for

# Get the connection IDs for all connections from the user $kill_user
processList=$(mysql -u$user -p$pass -s -e "SHOW FULL PROCESSLIST" | grep $kill_user | awk '{print $1}')
# Loop through all the connection IDs and kill the connection
for id in $processList
do
       result=$(mysql -u$user -p$pass -s -e "KILL $id")
       echo $result
done
</pre>
<p>The MySQL superuser account name and password, along with the user you want to kill all the connection for, are embedded within the script. It would be quite simple to pass these in as command line arguments if you wanted to though.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/mysql-connection-killer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Git and GitHub to Sync Config Files</title>
		<link>http://www.coderholic.com/using-git-and-github-to-sync-config-files/</link>
		<comments>http://www.coderholic.com/using-git-and-github-to-sync-config-files/#comments</comments>
		<pubDate>Sun, 25 Jan 2009 11:10:03 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=96</guid>
		<description><![CDATA[After years of using Linux I&#8217;ve built up a collection of customised config scripts for things like bash, vim, and screen. Having everything setup just how I want it is great, until I need to start working on a new computer. A simple solution is to copy all my config files over to the new [...]]]></description>
			<content:encoded><![CDATA[<p>After years of using Linux I&#8217;ve built up a collection of customised config scripts for things like bash, vim, and screen. Having everything setup just how I want it is great, until I need to start working on a new computer. A simple solution is to copy all my config files over to the new computer, but it means I need to re-copy all the config files if I make any changes to them. This isn&#8217;t too much of a problem if I&#8217;m only working on two computers, but it becomes a real pain with more.</p>
<p>The solution I&#8217;ve come up with (and I&#8217;m sure others have too) is to put all my config files into into a Git repository on <a href="http://github.com/">GitHub</a>. Any changes to the config files can be committed to the repository, and than a quick update operation other machines keeps all the config files in sync. In this post I&#8217;ll describe how to set it all up.</p>
<p><strong>Adding your config files to GitHub</strong></p>
<p>You&#8217;ll obviously need to install <a href="http://git-scm.com/">Git</a>. On any debian based system this is as simple as:</p>
<pre>   sudo aptitude install git-core</pre>
<p>You&#8217;ll also nee to <a href="https://github.com/signup/free">Signup</a> for a free GitHub account, and <a href="http://github.com/repositories/new">create a new repository</a>. GitHub uses public-key cryptography and SSH for authentication, so you&#8217;ll need to create a SSH public key on each machine you&#8217;ll be accessing GitHub from. Details of how to do this are given in their <a href="http://github.com/guides/providing-your-ssh-key">guide</a>. After adding your public key details to your GitHub <a href="https://github.com/account">account page</a> you&#8217;re ready to add your config files:</p>
<pre>  git init
  git add .bashrc
  git add .vimrc
  git add &lt;any other config files you want to add&gt;
  git commit -m 'Initial commit'
  git remote add origin git@github.com:coderholic/config.git # Your URL will differ
  git push origin master</pre>
<p>Now all your config files are on GitHub!</p>
<p><strong>Setting up a new machine</strong></p>
<p>You&#8217;ll need to create a SSH public key on the new machine, just as you did on the previous one. Once you&#8217;ve done that:</p>
<p>Once you&#8217;ve done that:</p>
<pre>  git init
  git pull git@github.com:coderholic/config.git
  git remote add origin git@github.com:coderholic/config.git</pre>
<p>And your setup will match your other machine!</p>
<p><strong>Making changes</strong></p>
<p>The real benefit of storing your config files on GitHub is that it makes it really easy to synchronise changes between all your computers. After making a change on one computer:</p>
<pre>  git commit -a -m "Useful commit message goes here"
  git push origin master
</pre>
<p>Then all you need to do on your other machines is issue the following command:</p>
<pre>
  git pull origin master
</pre>
<p>And you&#8217;re synced! </p>
<p>If you&#8217;re interested in seeing my config files you can see them on the GitHub page: <a href="http://github.com/coderholic/config/tree/master">http://github.com/coderholic/config/tree/master</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/using-git-and-github-to-sync-config-files/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>AVI to DVD Shell Script</title>
		<link>http://www.coderholic.com/avi-to-dvd-shell-script/</link>
		<comments>http://www.coderholic.com/avi-to-dvd-shell-script/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 19:09:46 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=107</guid>
		<description><![CDATA[Inspired by a movable tripe blog post I came up with the following shell script to convert an AVI file to an ISO image that can be burned to disc and played back on a standard DVD player. The script requires mencoder, ffmpeg, dvdauthor and mkisofs, and will let you know you if any of [...]]]></description>
			<content:encoded><![CDATA[<p>Inspired by a <a href="http://movabletripe.com/archive/merging-avis-into-a-single-dvd-on-linux/">movable tripe blog post</a> I came up with the following shell script to convert an AVI file to an ISO image that can be burned to disc and played back on a standard DVD player.</p>
<p>The script requires mencoder, ffmpeg, dvdauthor and mkisofs, and will let you know you if any of these are missing. Use it like follows:</p>
<blockquote><p>./dvd.sh input.avi</p></blockquote>
<p>Once the script has finished a &#8220;dvd.iso&#8221; file will be created, which can then be burned to DVD using your favourite disc burning tool.</p>
<pre class="php" name="code">
#!/bin/bash
# AVI to DVD Script
# Ben Dowling - www.coderholic.com

# Change to "ntsc" if you'd like to create NTSC disks
format="pal"

# Check we have enough command line arguments
if [ $# != 1 ]
then
	echo "Usage: $0 &lt;input file&gt;"
	exit
fi

# Check for dependencies
missing=0
dependencies=( "mencoder" "ffmpeg" "dvdauthor" "mkisofs" )
for command in ${dependencies[@]}
do
	if ! command -v $command &#038;>/dev/null
	then
		echo "$command not found"
		missing=1
	fi
done

if [ $missing = 1 ]
then
	echo "Please install the missing applications and try again"
	exit
fi

function emphasise() {
	echo ""
	echo "********** $1 **********"
	echo ""
}

# Check the file exists
input_file=$1
if [ ! -e $input_file ]
then
	echo "Input file not found"
	exit
fi

emphasise "Converting AVI to MPG"

ffmpeg -i finalmovie.avi -y -target ${format}-dvd -sameq -aspect 16:9 finalmovie.mpg

if [ $? != 0 ]
then
	emphasise "Conversion failed"
	exit
fi

emphasise "Creating DVD contents"

dvdauthor --title -o dvd -f finalmovie.mpg
first=$?
dvdauthor -o dvd -T
second=$?

if [ $first != 0 || $second != 0 ]
then
	emphasise "DVD Creation failed"
	exit
fi

emphasise "Creating ISO image"

mkisofs -dvd-video -o dvd.iso dvd/

if [ $? != 0 ]
then
	emphasise "ISO Creation failed"
	exit
fi

# Everything passed. Cleanup
rm -f finalmovie.mpg
rm -rf dvd/

emphasise "Success: dvd.iso image created"
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/avi-to-dvd-shell-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Server status checker shell script</title>
		<link>http://www.coderholic.com/server-status-checker-shell-script-2/</link>
		<comments>http://www.coderholic.com/server-status-checker-shell-script-2/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 13:28:36 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=95</guid>
		<description><![CDATA[It can be absolute nightmare if you find out on Monday morning that your web server was down all weekend, and all your potential visitors would have been greeted with an error message! This has happened to me a couple of times recently (fortunately not on this site), so I came up with an automated [...]]]></description>
			<content:encoded><![CDATA[<p>It can be absolute nightmare if you find out on Monday morning that your web server was down all weekend, and all your potential visitors would have been greeted with an error message! This has happened to me a couple of times recently (fortunately not on this site), so I came up with an automated checker. The shell script is below:</p>
<pre name="code" class="python">
#!/bin/bash

# Query a supplied URL and output an error message if
# the status code was not 200. Can be used as a cron
# task to check if a server is up or not.

# Ben Dowling - http://www.coderholic.com

# The URL to query
if [ $# -ne 1 ]
then
	echo "Usage: $0 &lt;URL&gt;";
	exit;
fi

url=$1;
response=$(curl -s -I -L $url | grep HTTP); 

status=${response#* }; # Strip off characters up to the first space
status=${status:0:3}; # Just use the 3 digit status code

if [ "$status" != "200" ]
then
	echo "Error fetching $url. Status code '$status'";
fi
</pre>
<p>I then set this up as a cron task to run every 15 minutes, and to email me if the site doesn&#8217;t respond with a HTTP 200 OK status:</p>
<pre>
*/15 * * * * /path/to/checkserver.sh "http://www.coderholic.com" | mail ben@coderholic.com
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/server-status-checker-shell-script-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Howto cd to a dir starting with -</title>
		<link>http://www.coderholic.com/howto-cd-to-a-dir-starting-with/</link>
		<comments>http://www.coderholic.com/howto-cd-to-a-dir-starting-with/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 16:38:23 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=88</guid>
		<description><![CDATA[I&#8217;ve been using Linux for over 10 years now, but I ran into a seemingly simple problem today that had me stumped. I wanted to change directory whose name started with a &#8220;-&#8221; character (a hypen, or dash). Here&#8217;s what happened: bmd /dir: ls -folder bmd /dir: cd -folder -bash: cd: -f: invalid option cd: [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using Linux for over 10 years now, but I ran into a seemingly simple problem today that had me stumped. I wanted to change directory whose name started with a &#8220;-&#8221; character (a hypen, or dash). Here&#8217;s what happened:</p>
<blockquote><p><strong>bmd /dir: ls</strong><br />
-folder<br />
<strong>bmd /dir: cd -folder</strong><br />
-bash: cd: -f: invalid option<br />
cd: usage: cd [-L|-P] [dir]<br />
<strong>bmd /dir: cd \-folder</strong><br />
-bash: cd: -f: invalid option<br />
cd: usage: cd [-L|-P] [dir]<br />
<strong>bmd /dir: cd &#8220;-folder&#8221;</strong><br />
-bash: cd: -f: invalid option<br />
cd: usage: cd [-L|-P] [dir]</p></blockquote>
<p>I wasn&#8217;t having much luck! It turns out solution is to pass &#8220;<code>--</code>&#8221; (two hypens) as the first argument to cd:</p>
<blockquote><p><b>bmd /dir: cd &#8212; -folder</b><br />
/home/bmd/dir/-folder<br />
<b>bmd /-folder: </b>
</p></blockquote>
<p>I think I remember having to use this trick in the past, but it&#8217;s such an infrequent problem that I obviously forgot about it. Hopefully by posting about it I&#8217;ll have a better change of remembering it for next time! <img src='http://www.coderholic.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/howto-cd-to-a-dir-starting-with/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
