<?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>Pario TechnoBlob &#187; Scripting</title>
	<atom:link href="http://pario.no/category/scripting/feed/" rel="self" type="application/rss+xml" />
	<link>http://pario.no</link>
	<description>A cronological documentation test project, nothing serious, really!</description>
	<lastBuildDate>Thu, 02 Feb 2012 13:17:58 +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>Recursively symlinking files</title>
		<link>http://pario.no/2012/02/02/recursively-symlinking-files/</link>
		<comments>http://pario.no/2012/02/02/recursively-symlinking-files/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 22:56:50 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[ln]]></category>
		<category><![CDATA[symlink]]></category>

		<guid isPermaLink="false">http://pario.no/?p=1693</guid>
		<description><![CDATA[This is a short script I use to symlink all my JPG image files on my file server to a flat folder accessible to my DLNA enabled devices. My files are organized in year folders and under each year there are month folders: -2011 --2011-01 --2011-02 --2011-03 ... -2012 --2012-01 I avoid duplicate symlinks by [...]]]></description>
			<content:encoded><![CDATA[<p>This is a short script I use to symlink all my JPG image files on my file server to a flat folder accessible to my DLNA enabled devices.<br />
My files are organized in year folders and under each year there are month folders:</p>
<pre>
-2011
--2011-01
--2011-02
--2011-03
...
-2012
--2012-01</pre>
<p>I avoid duplicate symlinks by using file names like 20110102-1234_DSC&#8230;JPG or YYYYMMDD-HHMM_OriginalFileName.JPG</p>
<p>The script looks like this</p>
<pre>
#!/bin/bash 

SRC="/media/Images"
DEST="/media/SymlinkTarget"

# Create a symlink under $DEST for each JPG file under $SRC
find $SRC -type f | grep -i jpg | while read PATHNAME; do
        NEW="$DEST";
        echo "$NEW";
        ln -s "$PATHNAME" "$NEW";
done</pre>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMTIvMDIvMDIvcmVjdXJzaXZlbHktc3ltbGlua2luZy1maWxlcy88d3B0Yj5SZWN1cnNpdmVseSBzeW1saW5raW5nIGZpbGVzPHdwdGI%2BaHR0cDovL3BhcmlvLm5vPHdwdGI%2BUGFyaW8gVGVjaG5vQmxvYg%3D%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2012/02/02/recursively-symlinking-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Lsyncd to perform &#8220;live&#8221; syncronization of a local directory to a remote directory</title>
		<link>http://pario.no/2012/01/13/using-lsyncd-to-perform-live-syncronization-of-a-local-directory-to-a-remote-directory/</link>
		<comments>http://pario.no/2012/01/13/using-lsyncd-to-perform-live-syncronization-of-a-local-directory-to-a-remote-directory/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 18:14:20 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[lsyncd]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[ssh-keygen]]></category>

		<guid isPermaLink="false">http://pario.no/?p=1672</guid>
		<description><![CDATA[This post is a short HOWTO and describes how you can install and run lsyncd to perform a rsync syncronization from local to a remote server using SSH. Lsyncd is a daemon to continuously synchronize directory trees and relies on inotify. If you need real live syncronization DRBD might be a better alternative since it [...]]]></description>
			<content:encoded><![CDATA[<p>This post is a short HOWTO and describes how you can install and run <a href="http://code.google.com/p/lsyncd/">lsyncd</a> to perform a rsync syncronization from local to a remote server using SSH.<br />
Lsyncd is a daemon to continuously synchronize directory trees and relies on inotify. If you need real live syncronization DRBD might be a better alternative since it is a block level syncronization. </p>
<p><strong>Installing Lsyncd 2.0 from source on CentOS 6</strong><br />
Lsyncd is not included as a package in CentOS 6, so you need to download the source file from <a href="http://code.google.com/p/lsyncd/downloads/list">http://code.google.com/p/lsyncd/downloads/list</a>.<br />
You should have rsync, GCC and lua-devel installed on your system before you continue installing Lsyncd.</p>
<pre>
# yum install rsync lua-devel</pre>
<p>Unpack the lsyncd source file and run the following commands from the unpacked file</p>
<pre>
# configure
# make
# make install</pre>
<p>make install copies the compiled files and install them to the right directories in your system.</p>
<p>I need to configure a non password SSH communication between the two servers with a shared SSH key.<br />
On the source server run the following command to generate a SSH key, if you have not done this already.<br />
Remember to do this as the user you are going to perform the sync with.</p>
<pre>
# ssh-keygen</pre>
<p>Secure copy the generated SSH key from the source server to your target server</p>
<pre>
# scp ~/.ssh/id_rsa.pub root@remoteserver:/tmp</pre>
<p>On the target server you need to add the copied SSH key to your existing authorized keys file.<br />
Also remember to do this with the user you are going to connect with from the source server.</p>
<pre>
# cat /tmp/id_rsa.pub >> ~/.ssh/authorized_keys</pre>
<p>If you do not have this file, just create it using the touch command described below</p>
<pre>
# touch ~/.ssh/authorized_keys</pre>
<p>Test if you can ssh without a password from your source server to the target server.</p>
<p>I have made a config file, <strong>/root/scripts/lsyncd.conf</strong> that tells Lsyncd where to put the log- and statusfile. That it should be running as a daemon in the background, and a sync should occur after 900 seconds (15 minutes) if there have not been any filesystem changes and there should not be more than 6 parallell Lsyncd processes.</p>
<pre>
settings = {
   logfile      = "/tmp/lsyncd.log",
   statusFile   = "/tmp/lsyncd.status",
   nodaemon     = false,
   maxDelays    = 900,
   maxProcesses = 6,
}

sync{default.rsyncssh, source="/path/on/source/", host="hostnam.target.server.tld", targetdir="/path/on/target/"}</pre>
<p>To start lsyncd you run the command</p>
<pre>
# lsyncd /root/scripts/lsyncd.conf</pre>
<p>You should now see a Lsyncd process running as a daemon on your system. It performs a sync when you start and then waits for any filesystem changes or sync after 900 seconds.</p>
<p>If you would like Lsyncd to start at boot, just add the following line to the bottom of file <strong>/etc/rc.local</strong></p>
<pre>
lsyncd /root/scripts/lsyncd.conf</pre>
<p>You do now have a working secure rsync syncronization between two servers.</p>
<p><strong>What directories you are syncing</strong></p>
<pre>
# tail -f /tmp/lsyncd.status</pre>
<p><strong>What is happening now</strong></p>
<pre>
# tail -f /tmp/lsyncd.log</pre>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/code.google.com\/p\/lsyncd\/","http:\/\/code.google.com\/p\/lsyncd\/downloads\/list"];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMTIvMDEvMTMvdXNpbmctbHN5bmNkLXRvLXBlcmZvcm0tbGl2ZS1zeW5jcm9uaXphdGlvbi1vZi1hLWxvY2FsLWRpcmVjdG9yeS10by1hLXJlbW90ZS1kaXJlY3RvcnkvPHdwdGI%2BVXNpbmcgTHN5bmNkIHRvIHBlcmZvcm0gJiM4MjIwO2xpdmUmIzgyMjE7IHN5bmNyb25pemF0aW9uIG9mIGEgbG9jYWwgZGlyZWN0b3J5IHRvIGEgcmVtb3RlIGRpcmVjdG9yeTx3cHRiPmh0dHA6Ly9wYXJpby5ubzx3cHRiPlBhcmlvIFRlY2hub0Jsb2I%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2012/01/13/using-lsyncd-to-perform-live-syncronization-of-a-local-directory-to-a-remote-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grab several screenshots from specified window in linux</title>
		<link>http://pario.no/2011/12/02/grab-several-screenshots-from-specified-window-in-linux/</link>
		<comments>http://pario.no/2011/12/02/grab-several-screenshots-from-specified-window-in-linux/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 07:23:01 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[PNG]]></category>
		<category><![CDATA[windowid]]></category>
		<category><![CDATA[wxd]]></category>

		<guid isPermaLink="false">http://pario.no/?p=1651</guid>
		<description><![CDATA[This was a short bash script I wrote to help document some startup problems on a server. The script was grabbing screen dumps from iDRAC during boot on a RHEL6 server, but it can be used on other distributions as well since the console command xwd is common. #!/bin/bash # Description: # Grab screenshot of [...]]]></description>
			<content:encoded><![CDATA[<p>This was a short bash script I wrote to help document some startup problems on a server.<br />
The script was grabbing screen dumps from iDRAC during boot on a RHEL6 server, but it can be used on other distributions as well since the console command xwd is common.</p>
<pre>
#!/bin/bash
# Description:
# Grab screenshot of a specified X-window and wait X-seconds

# Use xwininfo to find the Window id to the window you are going to
# grab screenshots from.
xwininfo="0x4c0001a"

# filename for output
outfile="outfile-"

# seconds sleep between grabs
sleeping=2

padding="000" # put as many padding zeros as you want on filename
for ((i=0; i<1000; i+=1))
do
        # Perform the actual screenshot grab
        xwd -id $xwininfo -out $outfile-${padding:${#i}}$i.xwd

        # Convert the xwd file to a better image format like PNG
        convert $outfile-${padding:${#i}}$i.xwd $outfile-${padding:${#i}}$i.png

        # Delete the converted XWD-file
        rm -f $outfile-${padding:${#i}}$i.xwd

        # wait
        sleep $sleeping
done</pre>
<p>Stop the script after you have grabbed enough screenshots.</p>
<p>I ended up with several files named outfile-000.png outfile-001.png ...<br />
Deleted those files that were not needed and sent the images a documentation of the booting process.</p>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMTEvMTIvMDIvZ3JhYi1zZXZlcmFsLXNjcmVlbnNob3RzLWZyb20tc3BlY2lmaWVkLXdpbmRvdy1pbi1saW51eC88d3B0Yj5HcmFiIHNldmVyYWwgc2NyZWVuc2hvdHMgZnJvbSBzcGVjaWZpZWQgd2luZG93IGluIGxpbnV4PHdwdGI%2BaHR0cDovL3BhcmlvLm5vPHdwdGI%2BUGFyaW8gVGVjaG5vQmxvYg%3D%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2011/12/02/grab-several-screenshots-from-specified-window-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to corrupt a disk partition using dd</title>
		<link>http://pario.no/2011/11/14/how-to-corrupt-a-disk-partition-using-dd/</link>
		<comments>http://pario.no/2011/11/14/how-to-corrupt-a-disk-partition-using-dd/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 10:49:39 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[dd]]></category>

		<guid isPermaLink="false">http://pario.no/?p=1628</guid>
		<description><![CDATA[I wanted to test corruption of a 41TB XFS filesystem and the dd command was the perfect tool for the job. I used a block size of 512 bytes and wrote 10 blocks of data from device /dev/urandom to the partition /dev/sdb1. The &#8220;Seek&#8221; option specifies how many blocks are skipped, counting 100 blocks from [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to test corruption of a 41TB XFS filesystem and the dd command was the perfect tool for the job.<br />
I used a block size of 512 bytes and wrote 10 blocks of data from device /dev/urandom to the partition /dev/sdb1.<br />
The &#8220;Seek&#8221; option specifies how many blocks are skipped, counting 100 blocks from the beginning of the partiton, before writing the random/corrupted data.</p>
<pre>
# dd bs=512 count=10 seek=100 if=/dev/urandom of=/dev/sdb1</pre>
<p><strong>Caution!</strong><br />
This procedure WILL most likely corrupt your disk partition or files on the partition. Use it ONLY on test systems and with a valid backup!</p>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMTEvMTEvMTQvaG93LXRvLWNvcnJ1cHQtYS1kaXNrLXBhcnRpdGlvbi11c2luZy1kZC88d3B0Yj5Ib3cgdG8gY29ycnVwdCBhIGRpc2sgcGFydGl0aW9uIHVzaW5nIGRkPHdwdGI%2BaHR0cDovL3BhcmlvLm5vPHdwdGI%2BUGFyaW8gVGVjaG5vQmxvYg%3D%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2011/11/14/how-to-corrupt-a-disk-partition-using-dd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove white space from file names</title>
		<link>http://pario.no/2011/11/10/remove-white-space-from-file-names/</link>
		<comments>http://pario.no/2011/11/10/remove-white-space-from-file-names/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 22:10:21 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[rename]]></category>

		<guid isPermaLink="false">http://pario.no/?p=1625</guid>
		<description><![CDATA[This is a one liner to remove white space in filenames using a linux console # rename 'y/ /_/' * You could also do this the other way, remove underscore with space # rename 'y/_//' *]]></description>
			<content:encoded><![CDATA[<p>This is a one liner to remove white space in filenames using a linux console</p>
<pre>
# rename 'y/ /_/'  *</pre>
<p>You could also do this the other way, remove underscore with space</p>
<pre>
# rename 'y/_//' *</pre>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMTEvMTEvMTAvcmVtb3ZlLXdoaXRlLXNwYWNlLWZyb20tZmlsZS1uYW1lcy88d3B0Yj5SZW1vdmUgd2hpdGUgc3BhY2UgZnJvbSBmaWxlIG5hbWVzPHdwdGI%2BaHR0cDovL3BhcmlvLm5vPHdwdGI%2BUGFyaW8gVGVjaG5vQmxvYg%3D%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2011/11/10/remove-white-space-from-file-names/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

