<?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>Erik's Lab &#187; Unix/Linux</title>
	<atom:link href="http://erikslab.com/category/unixlinux/feed/" rel="self" type="application/rss+xml" />
	<link>http://erikslab.com</link>
	<description>Things I'm working on, not necessarily functioning yet.</description>
	<lastBuildDate>Thu, 12 Jan 2012 14:20:20 +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>Just a Quick Reminder: ISPs, Check the RBLs!</title>
		<link>http://erikslab.com/2008/09/08/just-a-quick-reminder-isps-check-the-rbls/</link>
		<comments>http://erikslab.com/2008/09/08/just-a-quick-reminder-isps-check-the-rbls/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 14:33:20 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Unix/Linux]]></category>

		<guid isPermaLink="false">http://erikslab.com/2008/09/08/just-a-quick-reminder-isps-check-the-rbls/</guid>
		<description><![CDATA[A couple of minutes ago a friend told me, that one of his friends could not send mails via his SMTP-server. (Quick explanation: this friend of mine hosts a server on his premises and allowed a couple of his friends to use it for sending and receiving e-mail.) I checked the logs and lo and [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of minutes ago a friend told me, that one of his friends could not send mails via his SMTP-server. (Quick explanation: this friend of mine hosts a server on his premises and allowed a couple of his friends to use it for sending and receiving e-mail.) I checked the logs and lo and behold, the dynamic IP-address his friend was using was blocked by the RBL.</p>
<p>It seems, the person getting this very IP-address by the ISP before the poor soul in question used it to send spam and was blocked for doing so by the RBL. Is it that hard to check for the <i>own address-range</i> when getting the data-stream of an RBL (I&#8217;m 99% sure, that the ISP in question is using this very RBL to protect its own servers)? Obviously so. Hint: <code>grep [my_ip_range]</code> does the trick. <img src='http://erikslab.com/wp-includes/images/smilies/icon_mrgreen.gif' alt=':mrgreen:' class='wp-smiley' /> </p>
<p>Again, just a quick reminder. <img src='http://erikslab.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>[No, I won't name names.]</p>
]]></content:encoded>
			<wfw:commentRss>http://erikslab.com/2008/09/08/just-a-quick-reminder-isps-check-the-rbls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby: Simple Calculation of Billable Time using Epoch-Seconds</title>
		<link>http://erikslab.com/2007/10/18/ruby-simple-calculation-of-billable-time-using-epoch-seconds/</link>
		<comments>http://erikslab.com/2007/10/18/ruby-simple-calculation-of-billable-time-using-epoch-seconds/#comments</comments>
		<pubDate>Thu, 18 Oct 2007 15:01:16 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[OS X]]></category>
		<category><![CDATA[Unix/Linux]]></category>
		<category><![CDATA[epoch]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://erikslab.com/2007/10/18/ruby-simple-calculation-of-billable-time-using-epoch-seconds/</guid>
		<description><![CDATA[Two simple Ruby-scripts to calculate time in epoch-seconds.]]></description>
			<content:encoded><![CDATA[<p>How to calculate <em>billable time</em> in <a href="http://www.ruby-lang.org/en/">Ruby</a> using epoch-seconds. Out of interest,I ported the Perl-Code to Ruby and have to say, <i>wow</i>. Ruby is very elegant (not sure if my code is, but it works).</p>
<p>The idea was to use another (scripting-)language readily available on OS X. As I said already, it works like the Perl-version:</p>
<p><code><br />
#!/usr/bin/ruby</p>
<p># Variables<br />
starttime = Time.now<br />
epochtime = starttime.to_i</p>
<p># write to file<br />
timetemp = File.new("timetemp.txt", "w+")</p>
<p>timetemp.puts epochtime</p>
<p>timetemp.close # always close files</p>
<p>#output information for copying<br />
puts "customer|topic"<br />
puts "Start: #{starttime}"<br />
puts ""<br />
</code></p>
<p><code>start_record.rb</code> gets the current time in <em>epoch-seconds</em> and writes it to a file called <code>timetemp.txt</code> in the same directory. Nothing new here, but I like the construct <code>timetemp.puts epochtime</code>, Ruby is very clean. <img src='http://erikslab.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>When you&#8217;re done, <code>end_record.rb</code> is used to read in the starting time and to perform the necessary calculations:</p>
<p><code><br />
#!/usr/bin/ruby</p>
<p># Variables<br />
endtime = Time.now<br />
endsecs = endtime.to_i</p>
<p># open the file<br />
timetemp = File.open("timetemp.txt")</p>
<p>startsecs = timetemp.readline.to_i</p>
<p>timetemp.close # always close files</p>
<p>#calculations<br />
starttime = Time.at(startsecs)</p>
<p>timesecs = endsecs - startsecs</p>
<p>timeminutes = (timesecs.to_f / 60)</p>
<p>timehours = (timeminutes / 60)</p>
<p># output results<br />
puts "Start: #{starttime}"<br />
puts "End: #{endtime}"<br />
puts "Seconds: #{timesecs}"<br />
puts "Minutes: #{timeminutes}"<br />
puts "Hours: #{timehours}"<br />
puts ""<br />
puts "Bill: "<br />
puts ""<br />
</code></p>
<p>If you don&#8217;t want to copy and paste from the terminal-window, simply pipe the results to a file like this:</p>
<p><code>$ &gt; ruby start_record.rb &gt; my_file.txt</code></p>
<p>and when you&#8217;re done</p>
<p><code>$ &gt; ruby end_record.rb &gt;&gt; my_file.txt</code></p>
<p>Remember though, <code>&gt;</code> means overwrite the file if it exists. If you want to append, use <code>&gt;&gt;</code>. This might be obvious to most people fluent in UNIX, but should be noted as a &#8220;just in case you need to know&#8221;. <img src='http://erikslab.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
<script type="text/javascript"><!--
google_ad_client = "pub-1214196350274987";
//lab content small
google_ad_slot = "3229647765";
google_ad_width = 234;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>Technorati Tags: <a href="http://technorati.com/tag/Ruby" rel="tag">Ruby</a>, <a href="http://technorati.com/tag/epoch-seconds" rel="tag">epoch-seconds</a>, <a href="http://technorati.com/tag/calculating+with+epoch-seconds" rel="tag">calculating with epoch-seconds</a>, <a href="http://technorati.com/tag/OS+X" rel="tag">OS X</a>, <a href="http://technorati.com/tag/Linux" rel="tag">Linux</a></p>
]]></content:encoded>
			<wfw:commentRss>http://erikslab.com/2007/10/18/ruby-simple-calculation-of-billable-time-using-epoch-seconds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Calculation of Billable Time using epoch-seconds</title>
		<link>http://erikslab.com/2007/10/08/simple-calculation-of-billable-time-using-epoch-seconds/</link>
		<comments>http://erikslab.com/2007/10/08/simple-calculation-of-billable-time-using-epoch-seconds/#comments</comments>
		<pubDate>Mon, 08 Oct 2007 09:58:37 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[OS X]]></category>
		<category><![CDATA[Unix/Linux]]></category>
		<category><![CDATA[epoch]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://erikslab.com/2007/10/08/simple-calculation-of-billable-time-using-epoch-seconds/</guid>
		<description><![CDATA[How-To: A quick and dirty way to record billable time while away from your own machines.]]></description>
			<content:encoded><![CDATA[<p>Every freelancer uses some kind of accounting-package to keep track of the billable time, but, given multiple machines, on-site gigs and the like, keeping track is not always that easy, isn&#8217;t it? For that reason, I came up with a really simple combination of two Perl-scripts.</p>
<p>The first one, <code>start_record.pl</code>, writes the epoch-seconds to a temporary file and prints some information to the terminal-window.</p>
<p>Update: Thanks to Hebikai for pointing out a problem with the relative path, the scripts are using the environment-variable <code>$HOME</code> to determine the path now.</p>
<p><code><br />
	#!/usr/bin/perl</p>
<p>	$HOME_dir = $ENV{HOME};<br />
	$DATA_dir = "$HOME_dir/work/time_control_stuff";</p>
<p>	$start_time = time;</p>
<p>	#print "Seconds: $start_time\n";</p>
<p>	print "customer|topic\n";<br />
	print "Remarks: \n";<br />
	print localtime($start_time)."\n";</p>
<p>	open(MY_HANDLE, ">$DATA_dir/time.log") or die "$0: something went wrong: $!\n";<br />
	print MY_HANDLE $start_time."\n";<br />
	close(MY_HANDLE);<br />
</code></p>
<p>The script assumes, that there is a directory called <code>time_control_stuff</code> in <code>~/work/</code>. Its output should be copied or piped into a file, it records the time you started. If you want, feel free to modify the <code>customer|topic</code> and <code>Remarks</code> lines to taste.</p>
<p>If you are done with the task, the <code>end_record.pl</code> script comes into play.</p>
<p><code><br />
	#!/usr/bin/perl<br />
	$HOME_dir = $ENV{HOME};<br />
	$DATA_dir = "$HOME_dir/work/time_control_stuff";<br />
	$end_time = time;</p>
<p>	open(MY_HANDLE, "$DATA_dir/time.log") or die "$0: something went wrong: $!\n";</p>
<p>	while(<MY_HANDLE>)<br />
	{<br />
		chop;<br />
		$start_time = $_;</p>
<p>	}</p>
<p>	$total_time = $end_time - $start_time;<br />
	$total_mins = $total_time/60;<br />
	$total_hours = $total_mins/60;</p>
<p>	print "Start: ".localtime($start_time)."\n";</p>
<p>	print "End:   ".localtime($end_time)."\n";</p>
<p>	print "Total: ".$total_time."\n";<br />
	print "Mins: $total_mins\n";<br />
	print "Hours: $total_hours\n";<br />
	print "\nBill: \n\n";<br />
</code></p>
<p>Its output is pretty much self-explanatory, copy or append to the same file and you are done.</p>
<p>I use an USB-stick to carry the scripts with me all the time. If I need to record billable time and don&#8217;t have access to one of my machines, these scripts are my way to go. I input the recorded data into my accounting-package as soon as I&#8217;m able to do so.</p>
<p>Granted, they could be a lot more sophisticated, but remember KISS (Keep It Simple S…) rules. Use the scripts as a starting-point for you &#8220;accounting on the road.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://erikslab.com/2007/10/08/simple-calculation-of-billable-time-using-epoch-seconds/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Getting the current time in epoch-seconds</title>
		<link>http://erikslab.com/2007/10/06/getting-the-current-time-in-epoch-seconds/</link>
		<comments>http://erikslab.com/2007/10/06/getting-the-current-time-in-epoch-seconds/#comments</comments>
		<pubDate>Sat, 06 Oct 2007 16:38:24 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[OS X]]></category>
		<category><![CDATA[Unix/Linux]]></category>
		<category><![CDATA[epoch]]></category>

		<guid isPermaLink="false">http://erikslab.com/2007/10/06/getting-the-current-time-in-epoch-seconds/</guid>
		<description><![CDATA[How-To: Getting the current time in epoch-seconds in your shell and converting them back to human-readable time.]]></description>
			<content:encoded><![CDATA[<p>I already wrote about <a href="http://erikslab.com/2006/09/05/how-to-convert-an-epoch-time-to-a-meaningful-date-and-time/">epoch-seconds</a>, but there is a quicker way to get them, this time without resorting to Perl.</p>
<p><code>$ date "+%s"</code></p>
<p>Will return the current epoch-seconds, at the time of this writing <code>1191687083</code>. This should work with most incarnations of the <code>date</code>-command. For the restless (a.k.a. the ones not willing to read the post linked to above), converting from epoch-seconds to human-readable time works like this:</p>
<p><code>$ date -r 1191687083</code></p>
<p>Or whatever second-count you want to convert, of course. One last thing to try:</p>
<p><code>$ date -r 0000000000</code></p>
<p>Returns the time your system deems to be the beginning of its time, usually January 1st 1970.</p>
<p>I have no idea, if some of this works on Windows™, it should though, if you&#8217;d install <a href="http://www.cygwin.com/">cygwin</a> on it.</p>
<p>Technorati Tags: <a href="http://technorati.com/tag/OS+X" rel="tag">OS X</a>, <a href="http://technorati.com/tag/Linux" rel="tag">Linux</a>, <a href="http://technorati.com/tag/epoch+conversion" rel="tag">epoch conversion</a>, <a href="http://technorati.com/tag/epoch+seconds" rel="tag">epoch seconds</a></p>
]]></content:encoded>
			<wfw:commentRss>http://erikslab.com/2007/10/06/getting-the-current-time-in-epoch-seconds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using sed to transform XML to be displayed in HTML</title>
		<link>http://erikslab.com/2007/09/17/using-sed-to-transform-xml-to-be-displayed-in-html/</link>
		<comments>http://erikslab.com/2007/09/17/using-sed-to-transform-xml-to-be-displayed-in-html/#comments</comments>
		<pubDate>Mon, 17 Sep 2007 11:43:11 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[OS X]]></category>
		<category><![CDATA[Unix/Linux]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://erikslab.com/2007/09/17/using-sed-to-transform-xml-to-be-displayed-in-html/</guid>
		<description><![CDATA[One way to display XML in HTML without wrecking your Web site.]]></description>
			<content:encoded><![CDATA[<p>Pasting an XML-snippet into HTML can be full of surprises, the rendered result may not what you had in mind. Most browsers will try to interpret the snippet and you end up with something completely different. <img src='http://erikslab.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
If the XML to be used is still well-formed, XSLT is one option to transform the offending characters into entities, which in turn render the way they should in any web-browser. But, if we are talking about a couple of lines of XML, things are different. Since the XML isn&#8217;t well-formed any more, XSLT is not an option.<br />
A simple <code>sed</code> one-liner could look like this:</p>
<pre><code>sed 's/\\&lt;/\\&amp;lt;/g' file1.xml | sed 's/\\&gt;/\\&amp;gt;/g' &gt; file2.txt</code></pre>
<p>Let&#8217;s have a detailed look:</p>
<ol>
<li><code>sed</code> is called and</li>
<li>and told to perform a substitution <code>s</code> of all occurences of <code>&lt;</code> to <code>&amp;lt;</code> globally <code>g</code> in <code>file1.xml</code>.</li>
<li>The output goes via <code>|</code> to the second call of <code>sed</code> which</li>
<li>perfoms another substitution similar to the one in 2. This time for all occurences of &gt;.</li>
<li>The resulting text is written to <code>file2.txt</code>.</li>
</ol>
<p>Now you&#8217;re able to cut and paste snippets like this</p>
<pre><code>&lt;figure&gt;
  &lt;title&gt;Tags Window&lt;/title&gt;
  &lt;screenshot&gt;
&lt;mediaobject&gt;
  &lt;imageobject&gt;
    &lt;imagedata fileref="pictures/ch03/ch03-02tagswindow1.png"
      format="PNG" /&gt;
  &lt;/imageobject&gt;
&lt;/mediaobject&gt;
  &lt;/screenshot&gt;
&lt;/figure&gt;
&lt;para&gt;The menu of the &lt;quote&gt;Tags&lt;/quote&gt; window
allows us to create a new tag.&lt;/para&gt;
</code></pre>
<p>into the HTML-editor of your choice.</p>
<p>Technorati Tags: <a href="http://technorati.com/tag/displaying+XML+in+HTML" rel="tag">displaying XML in HTML</a>, <a href="http://technorati.com/tag/XML" rel="tag">XML</a>, <a href="http://technorati.com/tag/HTML" rel="tag">HTML</a></p>
]]></content:encoded>
			<wfw:commentRss>http://erikslab.com/2007/09/17/using-sed-to-transform-xml-to-be-displayed-in-html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CouchDB, Database re-invented?</title>
		<link>http://erikslab.com/2007/09/06/couchdb-database-re-invented/</link>
		<comments>http://erikslab.com/2007/09/06/couchdb-database-re-invented/#comments</comments>
		<pubDate>Thu, 06 Sep 2007 12:24:28 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Unix/Linux]]></category>

		<guid isPermaLink="false">http://erikslab.com/2007/09/06/couchdb-database-re-invented/</guid>
		<description><![CDATA[A document-centric, replicating database written in an object-oriented language called Erlang, sounds great.]]></description>
			<content:encoded><![CDATA[<p>I stumbled over a document-oriented, replicating Database named <a href="http://couchdb.org/">CouchDB</a>. It&#8217;s still in &#8220;alpha&#8221; but everything sounds <em>very</em> promising:</p>
<ul>
<li>Written in <a href="http://en.wikipedia.org/wiki/Erlang_%28programming_language%29">Erlang</a></li>
<li>Flat-file and document-centered</li>
<li>Replication built in</li>
<li>Runs on
<ol>
<li>Linux</li>
<li>OS X</li>
<li>Windows</li>
</ol>
</li>
<li>Open Source</li>
</ul>
<p>What&#8217;s not to like? And since the local database is replicated with the peers, <em>no backups</em>. But don&#8217;t forget to put two or three machines in another building. <img src='http://erikslab.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://erikslab.com/2007/09/06/couchdb-database-re-invented/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debian: resolvconf quick and dirty</title>
		<link>http://erikslab.com/2007/08/20/debian-resolvconf-quick-and-dirty/</link>
		<comments>http://erikslab.com/2007/08/20/debian-resolvconf-quick-and-dirty/#comments</comments>
		<pubDate>Mon, 20 Aug 2007 08:17:00 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Unix/Linux]]></category>

		<guid isPermaLink="false">http://erikslab.com/2007/08/20/debian-resolvconf-quick-and-dirty/</guid>
		<description><![CDATA[Two commands needed to modify your resolvconf-generated /etc/resolv.conf.]]></description>
			<content:encoded><![CDATA[<p>This is a &#8220;just in case you need to know&#8221;-post. If you are using the <a href="http://packages.debian.org/unstable/net/resolvconf">resolvconf</a>-package, you might stumble over the same problem as me: usually you don&#8217;t have to bother with the package after the initial configuration. So far, so good. <em>But</em> if you have to bother, let&#8217;s say you have to add another nameserver temporarily, use the following commands:</p>
<p><code>echo "nameserver xxx.xxx.xxx.xxx" | resolvconf -a mytemp</code></p>
<p>Obviously, you&#8217;ll have to change the &#8220;xxx&#8221; into a valid DNS-address and, as a bonus, you are free to choose another name instead of &#8220;mytemp&#8221;, just remember the name.</p>
<p>If you want to get rid of the nameserver-entry again, use the following command:</p>
<p><code>resolvconf -d mytemp</code></p>
<p>Again, if you replaced &#8220;mytemp&#8221; with a name of your choosing, use it.</p>
<p>Yeah, I know, but why should I memorize stuff like this if I can look it up here?</p>
]]></content:encoded>
			<wfw:commentRss>http://erikslab.com/2007/08/20/debian-resolvconf-quick-and-dirty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backing up with rsync</title>
		<link>http://erikslab.com/2007/07/20/backing-up-with-rsync/</link>
		<comments>http://erikslab.com/2007/07/20/backing-up-with-rsync/#comments</comments>
		<pubDate>Fri, 20 Jul 2007 07:09:54 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[OS X]]></category>
		<category><![CDATA[Unix/Linux]]></category>

		<guid isPermaLink="false">http://erikslab.com/2007/07/20/backing-up-with-rsync/</guid>
		<description><![CDATA[After writing the post Don&#8217;t forget to -&#160;-delete when rsyncing, I decided to write a little more about rsync, part of every well-groomed *NIX system, but Zonker was faster. Therefore, I&#8217;ll get out in the sun and present you with a link instead : Back up like an expert with rsync. Well done Zonker, you [...]]]></description>
			<content:encoded><![CDATA[<p>After writing the post <a href="http://erikslab.com/2007/02/07/dont-forget-to-delete-when-rsyncing/">Don&#8217;t forget to -&nbsp;-delete when rsyncing</a>, I decided to write a little more about <code>rsync</code>, part of every well-groomed *NIX system, but <a href="http://www.dissociatedpress.net/">Zonker</a> was faster. Therefore, I&#8217;ll get out in the sun and present you with a link instead <img src='http://erikslab.com/wp-includes/images/smilies/icon_mrgreen.gif' alt=':mrgreen:' class='wp-smiley' />  : <a href="http://www.linux.com/feature/117236">Back up like an expert with rsync</a>.</p>
<p>Well done Zonker, you gave me a couple of hours outside, THNX a million. <img src='http://erikslab.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://erikslab.com/2007/07/20/backing-up-with-rsync/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t forget to &#8211;delete when rsyncing</title>
		<link>http://erikslab.com/2007/02/07/dont-forget-to-delete-when-rsyncing/</link>
		<comments>http://erikslab.com/2007/02/07/dont-forget-to-delete-when-rsyncing/#comments</comments>
		<pubDate>Wed, 07 Feb 2007 18:50:45 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[OS X]]></category>
		<category><![CDATA[Unix/Linux]]></category>

		<guid isPermaLink="false">http://erikslab.com/2007/02/07/dont-forget-to-delete-when-rsyncing/</guid>
		<description><![CDATA[The program rsync is available on most *NIX/Linux platforms, but – contrary to the implication by its name – the program synchronizes only when used with the --delete-option. Let&#8217;s clarify first, what I mean by synchronizing: Assume we have a directory called fooboz, said directory contains two files, one named fooboz1.txt and another called fooboz2.txt. [...]]]></description>
			<content:encoded><![CDATA[<p>The program <code>rsync</code> is available on most *NIX/Linux platforms, but – contrary to the implication by its name – the program synchronizes only when used with the <code>--delete</code>-option.</p>
<p>Let&#8217;s clarify first, what I mean by <em>synchronizing</em>: Assume we have a directory called <code>fooboz</code>, said directory contains two files, one named <code>fooboz1.txt</code> and another called <code>fooboz2.txt</code>. We want to create a mirror of the directory in <code>fooboz_bu</code> and use the following command:</p>
<p><code>rsync -vaR /fooboz/ /fooboz_bu/</code></p>
<p>After the successful completion of the command, the directory <code>fooboz_bu</code> contains the directory <code>fooboz</code> with the two files <code>fooboz1.txt</code> and <code>fooboz2.txt</code>. You might have guessed it, the <code>-vaR</code>-option means: be verbose (<code>v</code>), run in archive-mode (<code>a</code>), and do it recursively (<code>R</code>). Archive-mode means, that pretty much everything is a perfect mirror of the source.</p>
<p>If I modify a file in <code>fooboz</code>, it will be copied during the next invocation of the <code>rsync</code>-command shown above. What if I delete one of the files? Right, nothing. The file will be missing in the source-directory, but will prevail in the backup-directory unless we add the <code>--delete</code>-option to the command, that is:</p>
<p><code>rsync -vaR --delete /fooboz/ /fooboz_bu/</code></p>
<p>Now the two directories will be in sync, means, after the latter command completes, both directories will look the same.</p>
<p><strong>Disclaimer:</strong> Do a test-run on data you could afford to loose, seriously. If you should get something wrong with this command, you might destroy the very data you wanted to backup.</p>
<p>Technorati Tags: <a href="http://technorati.com/tag/rsync" rel="tag">rsync</a>, <a href="http://technorati.com/tag/syncing+directories" rel="tag">syncing directories</a></p>
]]></content:encoded>
			<wfw:commentRss>http://erikslab.com/2007/02/07/dont-forget-to-delete-when-rsyncing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to convert an &#8220;epoch&#8221;-time to a meaningful date and time</title>
		<link>http://erikslab.com/2006/09/05/how-to-convert-an-epoch-time-to-a-meaningful-date-and-time/</link>
		<comments>http://erikslab.com/2006/09/05/how-to-convert-an-epoch-time-to-a-meaningful-date-and-time/#comments</comments>
		<pubDate>Tue, 05 Sep 2006 09:05:02 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[OS X]]></category>
		<category><![CDATA[Unix/Linux]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[epoch]]></category>

		<guid isPermaLink="false">http://erikslab.com/2006/09/05/how-to-convert-an-epoch-time-to-a-meaningful-date-and-time/</guid>
		<description><![CDATA[How-To: If all you got is an epoch-time, how do you convert it into something more useful for human consumption?]]></description>
			<content:encoded><![CDATA[<p>Most, if not all *NIX-based systems store time and date values as <a href="http://en.wikipedia.org/wiki/Unix_Epoch" title="epoch explanation on wikipedia">epoch</a>, means in seconds after a certain date, usually the seconds passed since 00:00:00 UTC Jan 1, 1970. Not a perfect approach, but sufficently accurate for most purposes. If you are confronted with such a value, then there are a couple of apporaches to convert it to something meaningful. The easiest way (again, on *NIX-based systems) is the following command:</p>
<p><code>date -r epoch_seconds</code></p>
<p>it returns a date-string readable by humans (and other beings familiar with the time-system used on earth). An example says more than any complicated explanation:</p>
<p><code>$ perl -e 'print time."\n";'<br />
1157445071<br />
$ date -r 1157445071<br />
Tue Sep  5 10:31:11 CEST 2006</code></p>
<p>BTW: The perl-comand shown above comes handy if you need to know the current time in epoch-seconds.</p>
<p>But, the fun doesn&#8217;t stop here. Recently I had to convert epoch-times and do some calculations with it. Lazy as I am (you already got that, didn&#8217;t you), I decided to use AppleScript to do the calculations, but since I could not find an AppleScript-function capable of converting epoch-seconds, I used its capabilities to access the *NIX-brain beneath the pretty GUI. Without further ado, here is a handler to do the calculation:</p>
<pre><code class="as">
<span class="bluebold">on</span> <span class="greenreg">epoch2datetime</span>(<span class="greenreg">epochseconds</span>)
	<span class="bluebold">set</span> <span class="greenreg">myshell1</span> <span class="bluebold">to</span> "date -r "
	<span class="bluebold">set</span> <span class="greenreg">myshell2</span> <span class="bluebold">to</span> " \"+%m/%d/%Y %H:%M\""

	<span class="bluebold">set</span> <span class="greenreg">theDatetime</span> <span class="bluebold">to</span> <span class="bluereg">do shell script</span> (<span class="greenreg">myshell1</span> &amp; <span class="greenreg">epochseconds</span> &amp; <span class="greenreg">myshell2</span>)

	<span class="bluebold">return</span> <span class="bluereg">date</span> <span class="greenreg">theDatetime</span>
<span class="bluebold">end</span> <span class="greenreg">epoch2datetime</span>
</code></pre>
<p>The return-value is fit to be fed into an AppleScript-command which converts it into a date-time value AppleScript can work with.</p>
<p>Hope this helps. <img src='http://erikslab.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' />  BTW: <del>I&#8217;ll try to figure out how to color the AppleScript later.</del> Be careful if you do a copy and paste with the code shown, WordPress insists on messing up the quotes, sorry.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-1214196350274987";
//lab content small
google_ad_slot = "3229647765";
google_ad_width = 234;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
Technorati Tags: <a href="http://technorati.com/tag/OS+X" rel="tag">OS X</a>, <a href="http://technorati.com/tag/AppleScript" rel="tag">AppleScript</a>, <a href="http://technorati.com/tag/epoch+conversion" rel="tag">epoch conversion</a>,</p>
]]></content:encoded>
			<wfw:commentRss>http://erikslab.com/2006/09/05/how-to-convert-an-epoch-time-to-a-meaningful-date-and-time/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

