<?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>Simon Cook &#187; bash</title>
	<atom:link href="http://simoncook.org/blog/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://simoncook.org</link>
	<description>The future is... on a CD? Now where&#039;s that blasted disc gone?</description>
	<lastBuildDate>Sun, 22 Aug 2010 19:43:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Minecraft Tools: SnapShotter 1.0</title>
		<link>http://simoncook.org/blog/2010/08/minecraft-tools-snapshotter-1-0/</link>
		<comments>http://simoncook.org/blog/2010/08/minecraft-tools-snapshotter-1-0/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 10:58:34 +0000</pubDate>
		<dc:creator>Si</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[minecraft]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://simoncook.org/?p=573</guid>
		<description><![CDATA[Although I did post this on the Minecraft Forums, I think I should post this here for anyone who wants to see how simple this script is. What it does is to take a copy of the Minecraft map and copy it to a folder for people to grab (also good for backups when someone [...]]]></description>
			<content:encoded><![CDATA[<p>Although I did post this on the <a href="http://www.minecraftforum.net/viewtopic.php?f=1012&amp;t=27116">Minecraft Forums</a>, I think I should post this here for anyone who wants to see how simple this script is.</p>
<p>What it does is to take a copy of the Minecraft map and copy it to a folder for people to grab (also good for backups when someone TNTs the hell out of your map). If you have any suggestions/improvements, feel free to comment.</p>
<p>(To stop the spamming of rubbish your RSS reader won&#8217;t understand I&#8217;ll put the code under the break.)</p>
<p><span id="more-573"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># Minecraft World Snapshotter</span>
<span style="color: #666666; font-style: italic;"># Version 1.0</span>
<span style="color: #666666; font-style: italic;"># Created by Simon Cook (simon@simoncook.org)</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## CONFIG START</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># WORLD contains the name of the directory the Minecraft world is in</span>
<span style="color: #007800;">WORLD</span>=<span style="color: #ff0000;">&quot;world&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># FILENAME contains the name that will be appended with the date</span>
<span style="color: #007800;">FILENAME</span>=<span style="color: #ff0000;">&quot;world2-&quot;</span>
<span style="color: #666666; font-style: italic;"># DATE contains the date formatting to be used for a file name</span>
<span style="color: #007800;">DATE</span>=<span style="color: #ff0000;">&quot;%Y%m%d-%H%M%S&quot;</span>
<span style="color: #666666; font-style: italic;"># TYPE defines the file type to create (valid: tar bz2 7z zip)</span>
<span style="color: #007800;">TYPE</span>=<span style="color: #ff0000;">&quot;7z&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># DEST if valid, the snapshot will be copied or moved to this directory</span>
<span style="color: #007800;">DEST</span>=<span style="color: #ff0000;">&quot;/var/www/simoncook.org/web/static/minecraft/&quot;</span>
<span style="color: #666666; font-style: italic;"># CPMV is whether to move or copy if DEST is valid (valid: cp mv)</span>
<span style="color: #007800;">CPMV</span>=<span style="color: #ff0000;">&quot;cp&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## CONFIG END</span>
<span style="color: #666666; font-style: italic;">## DO NOT EDIT UNDER THIS LINE</span>
&nbsp;
<span style="color: #007800;">FILENAME</span>=<span style="color: #007800;">$FILENAME</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #007800;">$DATE</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$WORLD</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Sorry, World <span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">$WORLD</span><span style="color: #000099; font-weight: bold;">\&quot;</span> does not exist!&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TYPE</span>&quot;</span> == <span style="color: #ff0000;">&quot;tar&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #007800;">FILENAME</span>=<span style="color: #007800;">$FILENAME</span>.tar
    <span style="color: #c20cb9; font-weight: bold;">tar</span> cf <span style="color: #007800;">$FILENAME</span> <span style="color: #007800;">$WORLD</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Snapshot created as <span style="color: #007800;">$FILENAME</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TYPE</span>&quot;</span> == <span style="color: #ff0000;">&quot;bz2&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #007800;">FILENAME</span>=<span style="color: #007800;">$FILENAME</span>.tar
    <span style="color: #c20cb9; font-weight: bold;">tar</span> cf <span style="color: #007800;">$FILENAME</span> <span style="color: #007800;">$WORLD</span>
    <span style="color: #c20cb9; font-weight: bold;">bzip2</span> <span style="color: #660033;">-9</span> <span style="color: #007800;">$FILENAME</span>
    <span style="color: #007800;">FILENAME</span>=<span style="color: #007800;">$FILENAME</span>.bz2
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Snapshot created as <span style="color: #007800;">$FILENAME</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TYPE</span>&quot;</span> == <span style="color: #ff0000;">&quot;7z&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #007800;">FILENAME</span>=<span style="color: #007800;">$FILENAME</span>.7z
    7za a <span style="color: #660033;">-mx9</span> <span style="color: #007800;">$FILENAME</span> <span style="color: #007800;">$WORLD</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Snapshot created as <span style="color: #007800;">$FILENAME</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TYPE</span>&quot;</span> == <span style="color: #ff0000;">&quot;zip&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #007800;">FILENAME</span>=<span style="color: #007800;">$FILENAME</span>.zip
    <span style="color: #c20cb9; font-weight: bold;">zip</span> <span style="color: #660033;">-9rq</span> <span style="color: #007800;">$FILENAME</span> <span style="color: #007800;">$WORLD</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Snapshot created as <span style="color: #007800;">$FILENAME</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DEST</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CPMV</span>&quot;</span> == <span style="color: #ff0000;">&quot;mv&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$FILENAME</span> <span style="color: #007800;">$DEST</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;File moved to <span style="color: #007800;">$DEST</span>&quot;</span>
    <span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CPMV</span>&quot;</span> == <span style="color: #ff0000;">&quot;cp&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #007800;">$FILENAME</span> <span style="color: #007800;">$DEST</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;File copied to <span style="color: #007800;">$DEST</span>&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://simoncook.org/blog/2010/08/minecraft-tools-snapshotter-1-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pulling random data from /dev/random</title>
		<link>http://simoncook.org/blog/2010/02/pulling-random-data-from-devrandom/</link>
		<comments>http://simoncook.org/blog/2010/02/pulling-random-data-from-devrandom/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 06:55:44 +0000</pubDate>
		<dc:creator>Si</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[/dev/random]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://simoncook.org/?p=408</guid>
		<description><![CDATA[This is a shell script that will pull 5 random characters from /dev/random and print them out to standard output. It was created as the input component for a random password generator that I am currently writing. Note on using /dev/random: as usual, using this source for entropy will give you pure randomness, though due [...]]]></description>
			<content:encoded><![CDATA[<p>This is a shell script that will pull 5 random characters from /dev/random and print them out to standard output. It was created as the input component for a random password generator that I am currently writing.</p>
<p><strong>Note on using /dev/random</strong>: as usual, using this source for entropy will give you pure randomness, though due to the nature of the random source (see <a href="http://en.wikipedia.org/wiki//dev/random">Wikipedia entry on /dev/random</a>) the script may sometimes lock up and fail to generate a complete output, as it has run out of randomness. If you are intending to use this alot, then it is advised to use /dev/urandom that doesn&#8217;t block, although that comes at the cost of a small bit of entropy.<br />
<span id="more-408"></span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># Script for pulling x characters from a random source</span>
<span style="color: #666666; font-style: italic;">#   and prints them out to stdout</span>
<span style="color: #666666; font-style: italic;"># Version 1.0.0</span>
<span style="color: #666666; font-style: italic;"># By Simon Cook (http://simoncook.org)</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Fill in the two variables below</span>
<span style="color: #666666; font-style: italic;">#  &quot;entropy&quot; is the source of randomness</span>
<span style="color: #666666; font-style: italic;">#  &quot;chars&quot; is the number of chars we want</span>
<span style="color: #007800;">entropy</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>random
<span style="color: #007800;">chars</span>=<span style="color: #000000;">5</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Pull x characters from source</span>
<span style="color: #007800;">i</span>=<span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #660033;">-r</span> <span style="color: #660033;">-n1</span> char
<span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$char</span>&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> i++ <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span>&quot;</span> <span style="color: #660033;">-eq</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$chars</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
   <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span>
   <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span> <span style="color: #000000; font-weight: bold;">&amp;</span>lt; <span style="color: #ff0000;">&quot;<span style="color: #007800;">$entropy</span>&quot;</span></pre></div></div>

<p><strong> Licensing:</strong> This small script is released under the CC-GNU GPL licence.</p>
<p><!-- Creative Commons License --><br />
<a href="http://creativecommons.org/licenses/GPL/2.0/"><br />
<img src="http://creativecommons.org/images/public/cc-GPL-a.png" border="0" alt="CC-GNU GPL" /></a><!-- /Creative Commons License -->.</p>
]]></content:encoded>
			<wfw:commentRss>http://simoncook.org/blog/2010/02/pulling-random-data-from-devrandom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
