<?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>Mad Python &#187; shell</title>
	<atom:link href="http://blog.madpython.com/tag/shell/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.madpython.com</link>
	<description>Watch out.. he's angry</description>
	<lastBuildDate>Thu, 04 Nov 2010 14:19:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Ahh those cool little CLI tools&#8230;</title>
		<link>http://blog.madpython.com/2009/03/01/ahh-those-cool-little-cli-tools/</link>
		<comments>http://blog.madpython.com/2009/03/01/ahh-those-cool-little-cli-tools/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 19:37:19 +0000</pubDate>
		<dc:creator>Xavier</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://blog.madpython.com/?p=4</guid>
		<description><![CDATA[The list of Unix/Linux utilities available grows every day. Here&#8217;s a little list of cherry-picked utilities i&#8217;ve found myself using more and more lately&#8230; Inotail: Inotail uses the Linux kernel&#8217;s inotify API, which was implemented with v2.6.13 to monitor changes &#8230; <a href="http://blog.madpython.com/2009/03/01/ahh-those-cool-little-cli-tools/">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://blog.madpython.com/2009/03/07/extending-postgresql-with-python/' rel='bookmark' title='Extending PostgreSQL with Python'>Extending PostgreSQL with Python</a></li>
<li><a href='http://blog.madpython.com/2009/03/02/apache2-shortcuts/' rel='bookmark' title='Apache2 shortcuts'>Apache2 shortcuts</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The list of Unix/Linux utilities available grows every day. Here&#8217;s a little list of cherry-picked utilities i&#8217;ve found myself using more and more lately&#8230;</p>
<h4>Inotail:</h4>
<p>Inotail uses the Linux kernel&#8217;s <em>inotify</em> API, which was implemented with v2.6.13 to monitor changes to files on the filesystem. This design is more efficient than our beloved <em>tail</em>, which relies on polling the monitored file for changes every second.  Example: To monitor in real-time syslog entries, try:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">inotail <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>messages</pre></div></div>

<p>The documentation for inotail, if you need it, can be found at <a href="http://distanz.ch/inotail/" onclick="return TrackClick('http%3A%2F%2Fdistanz.ch%2Finotail%2F','http%3A%2F%2Fdistanz.ch%2Finotail%2F')" target="_blank">http://distanz.ch/inotail/</a></p>
<h4>Incron:</h4>
<p>Incron is an event-scheduler similar to <em>cron</em>, except that it is based on file-system events as opposed to our beloved time-based <em>cron</em> daemons. It is also based on the <em>inotify</em> subsystem, which means it is only available on Linux as far as I know.  Let&#8217;s set up a quick example to demonstrate the stuff you can do with incron. We&#8217;re going to install incron, and configure it to automatically create a thumbnail of any picture dropped in a specified directory using ImageMagick&#8217;s <em>convert</em> utility, on a stock Ubuntu Linux system:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Package installation</span>
<span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> incron imagemagick
<span style="color: #666666; font-style: italic;"># Add your user account to the list of allowed incron users (replace xavier by your account)</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;echo xavier &gt;&gt; /etc/incron.allow&quot;</span>
<span style="color: #666666; font-style: italic;"># Create our directory structure</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>xavier<span style="color: #000000; font-weight: bold;">/</span>images<span style="color: #000000; font-weight: bold;">/</span>original
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>xavier<span style="color: #000000; font-weight: bold;">/</span>images<span style="color: #000000; font-weight: bold;">/</span>thumb
<span style="color: #666666; font-style: italic;"># Edit the actual incron file</span>
incrontab <span style="color: #660033;">--edit</span></pre></div></div>

<p>The editor will now fire up. Enter the following lines in the editor, and exit:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Convert /home/xavier/images/original/test.png to /home/xavier/images/thumb/test.png</span>
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>xavier<span style="color: #000000; font-weight: bold;">/</span>images<span style="color: #000000; font-weight: bold;">/</span>original<span style="color: #000000; font-weight: bold;">/</span>   IN_CLOSE_WRITE    convert <span style="color: #660033;">-thumbnail</span> 320x320 $<span style="color: #000000; font-weight: bold;">@/</span><span style="color: #007800;">$#</span> $<span style="color: #000000; font-weight: bold;">@/</span>..<span style="color: #000000; font-weight: bold;">/</span>thumb<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$#</span>
<span style="color: #666666; font-style: italic;"># When an original is deleted, automatically clean up the associated thumbnail</span>
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>xavier<span style="color: #000000; font-weight: bold;">/</span>images<span style="color: #000000; font-weight: bold;">/</span>original<span style="color: #000000; font-weight: bold;">/</span>   IN_DELETE    <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> $<span style="color: #000000; font-weight: bold;">@/</span>..<span style="color: #000000; font-weight: bold;">/</span>thumb<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$#</span></pre></div></div>

<p>We&#8217;re all done. Any new image dropped in /home/xavier/images/original/ will automatically be converted into a thumbnail of the same name in /home/xavier/images/thumb/.  There are many things you can do with incron, so i suggest you check out the following links:</p>
<ul>
<li>Incron Documentation: <a href="http://inotify.aiken.cz/?section=incron&amp;page=doc&amp;lang=en" onclick="return TrackClick('http%3A%2F%2Finotify.aiken.cz%2F%3Fsection%3Dincron%26amp%3Bpage%3Ddoc%26amp%3Blang%3Den','http%3A%2F%2Finotify.aiken.cz%2F%3Fsection%3Dincron%26amp%3Bpage%3Ddoc%26amp%3Blang%3Den')" target="_blank">http://inotify.aiken.cz/?section=incron&amp;page=doc&amp;lang=en</a></li>
<li>Incron FAQ: <a href="http://inotify.aiken.cz/?section=incron&amp;page=faq&amp;lang=en" onclick="return TrackClick('http%3A%2F%2Finotify.aiken.cz%2F%3Fsection%3Dincron%26amp%3Bpage%3Dfaq%26amp%3Blang%3Den','http%3A%2F%2Finotify.aiken.cz%2F%3Fsection%3Dincron%26amp%3Bpage%3Dfaq%26amp%3Blang%3Den')" target="_blank">http://inotify.aiken.cz/?section=incron&amp;page=faq&amp;lang=en</a></li>
<li>inotify.h: <a href="http://www.kernel.org/pub/linux/kernel/people/rml/inotify/headers/inotify.h" onclick="return TrackClick('http%3A%2F%2Fwww.kernel.org%2Fpub%2Flinux%2Fkernel%2Fpeople%2Frml%2Finotify%2Fheaders%2Finotify.h','http%3A%2F%2Fwww.kernel.org%2Fpub%2Flinux%2Fkernel%2Fpeople%2Frml%2Finotify%2Fheaders%2Finotify.h')" target="_blank">http://www.kernel.org/pub/linux/kernel/people/rml/inotify/headers/inotify.h</a></li>
</ul>
<h4>ccze</h4>
<p>ccze is simply a logfile syntax highlighter for various file-formats commonly found on unix systems, such as <em>syslog, apache logs, dmesg</em>, etc&#8230;  You can have it syntax-highlight a file in your terminal by using the following syntax:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ccze <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>messages</pre></div></div>

<p>Or you can pipe anything onto ccze to have it stream syntax-coloured output on your terminal. For example:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">inotail <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>messages <span style="color: #000000; font-weight: bold;">|</span> ccze <span style="color: #660033;">-A</span></pre></div></div>

<p>Additionally, ccze can also output syntax-coloured text in HTML. For example, the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">dmesg</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-i</span> cpu <span style="color: #000000; font-weight: bold;">|</span> ccze <span style="color: #660033;">-m</span> html</pre></div></div>

<p>Woud output the following document: <a href="http://blog.madpython.com/wp-content/uploads/2009/03/cpu.html" onclick="return TrackClick('http%3A%2F%2Fblog.madpython.com%2Fwp-content%2Fuploads%2F2009%2F03%2Fcpu.html','ccze+Output')">ccze Output</a></p>
<p><a class="a2a_button_reddit" href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fblog.madpython.com%2F2009%2F03%2F01%2Fahh-those-cool-little-cli-tools%2F&amp;linkname=Ahh%20those%20cool%20little%20CLI%20tools%26%238230%3B" title="Reddit" rel="nofollow" target="_blank"><img src="http://blog.madpython.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.madpython.com%2F2009%2F03%2F01%2Fahh-those-cool-little-cli-tools%2F&amp;linkname=Ahh%20those%20cool%20little%20CLI%20tools%26%238230%3B" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.madpython.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fblog.madpython.com%2F2009%2F03%2F01%2Fahh-those-cool-little-cli-tools%2F&amp;linkname=Ahh%20those%20cool%20little%20CLI%20tools%26%238230%3B" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://blog.madpython.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fblog.madpython.com%2F2009%2F03%2F01%2Fahh-those-cool-little-cli-tools%2F&amp;linkname=Ahh%20those%20cool%20little%20CLI%20tools%26%238230%3B" title="Facebook" rel="nofollow" target="_blank"><img src="http://blog.madpython.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_stumbleupon" href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fblog.madpython.com%2F2009%2F03%2F01%2Fahh-those-cool-little-cli-tools%2F&amp;linkname=Ahh%20those%20cool%20little%20CLI%20tools%26%238230%3B" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://blog.madpython.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fblog.madpython.com%2F2009%2F03%2F01%2Fahh-those-cool-little-cli-tools%2F&amp;linkname=Ahh%20those%20cool%20little%20CLI%20tools%26%238230%3B" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://blog.madpython.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fblog.madpython.com%2F2009%2F03%2F01%2Fahh-those-cool-little-cli-tools%2F&amp;linkname=Ahh%20those%20cool%20little%20CLI%20tools%26%238230%3B" title="Twitter" rel="nofollow" target="_blank"><img src="http://blog.madpython.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.madpython.com%2F2009%2F03%2F01%2Fahh-those-cool-little-cli-tools%2F&amp;title=Ahh%20those%20cool%20little%20CLI%20tools%26%238230%3B" id="wpa2a_2">Share</a></p><p>Related posts:<ol>
<li><a href='http://blog.madpython.com/2009/03/07/extending-postgresql-with-python/' rel='bookmark' title='Extending PostgreSQL with Python'>Extending PostgreSQL with Python</a></li>
<li><a href='http://blog.madpython.com/2009/03/02/apache2-shortcuts/' rel='bookmark' title='Apache2 shortcuts'>Apache2 shortcuts</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.madpython.com/2009/03/01/ahh-those-cool-little-cli-tools/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

