<?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; perl</title>
	<atom:link href="http://pario.no/tag/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://pario.no</link>
	<description>A cronological documentation test project, nothing serious, really!</description>
	<lastBuildDate>Thu, 26 Apr 2012 08:18:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Rename files in a folder to lower-case using perl</title>
		<link>http://pario.no/2008/10/13/rename-files-in-a-folder-to-lower-case-using-perl/</link>
		<comments>http://pario.no/2008/10/13/rename-files-in-a-folder-to-lower-case-using-perl/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 08:12:40 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[rename]]></category>

		<guid isPermaLink="false">http://pario.no/?p=751</guid>
		<description><![CDATA[This is a simple oneliner to rename files to lower-case using perl # perl -e 'rename($_, lc) &#124;&#124; warn "$_: $!\n" for @ARGV' * You can also do this recusively using find and perl # find . -type f -exec perl -e 'rename($_, lc) &#124;&#124; warn "$_: $!\n" for @ARGV' {} \;]]></description>
			<content:encoded><![CDATA[<p>This is a simple oneliner to rename files to lower-case using perl</p>
<pre>
# perl -e 'rename($_, lc) || warn "$_: $!\n" for @ARGV' *</pre>
<p>You can also do this recusively using find and perl</p>
<pre>
# find . -type f -exec perl -e 'rename($_, lc) || warn "$_: $!\n" for @ARGV' {} \;</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 = "aHR0cDovL3BhcmlvLm5vLzIwMDgvMTAvMTMvcmVuYW1lLWZpbGVzLWluLWEtZm9sZGVyLXRvLWxvd2VyLWNhc2UtdXNpbmctcGVybC88d3B0Yj5SZW5hbWUgZmlsZXMgaW4gYSBmb2xkZXIgdG8gbG93ZXItY2FzZSB1c2luZyBwZXJsPHdwdGI%2BaHR0cDovL3BhcmlvLm5vPHdwdGI%2BUGFyaW8gVGVjaG5vQmxvYg%3D%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2008/10/13/rename-files-in-a-folder-to-lower-case-using-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8216;tail -f&#8217; with highlight</title>
		<link>http://pario.no/2008/09/03/tail-f-with-highlight/</link>
		<comments>http://pario.no/2008/09/03/tail-f-with-highlight/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 09:01:21 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[tail]]></category>

		<guid isPermaLink="false">http://pario.no/?p=560</guid>
		<description><![CDATA[This is an example of how you can use tail with colors. # tail -f /var/log/maillog &#124; perl -pe 's/colorthisword/\e[1;32;40m$&#038;\e[0m/g' The ;;; values explained 0 all attributes off 1 bold 32 foreground green 40 background black &#8220;colorthisword&#8221; can be any perl regular expression: (foo&#124;bar) highlight the strings foo and bar \b((foo&#124;bar)\b highlight the words foo [...]]]></description>
			<content:encoded><![CDATA[<p>This is an example of how you can use <b>tail</b> with colors.</p>
<pre>
# tail -f /var/log/maillog | perl -pe 's/colorthisword/\e[1;32;40m$&#038;\e[0m/g'</pre>
<p><b>The ;;; values explained</b></p>
<table border=1>
<tr>
<td>0 </td>
<td> all attributes off</td>
</tr>
<tr>
<td>1 </td>
<td> bold</td>
<p></tR></p>
<tr>
<td>32 </td>
<td> foreground green</td>
</tr>
<tr>
<td>40 </td>
<td> background black</td>
</tr>
</table>
<p>&#8220;colorthisword&#8221; can be any perl regular expression:</p>
<table border=1>
<tr>
<td>(foo|bar)</td>
<td> highlight the strings foo and bar</td>
</tr>
<tr>
<td>\b((foo|bar)\b</td>
<td> highlight the words foo and bar</td>
</tr>
<tr>
<td>.*\b((foo|bar)\b.*</td>
<td> highlight the whole line that contains the words foo or bar</td>
</tr>
</table>
<p><b>Colors</b><br />
This vector holds the colors used for SGR control sequences parameters 30 to 37 \(foreground colors) and 40 to 47 (background colors).</p>
<table border=1>
<tr>
<th colspan=2>Parameter</th>
<th>Color</th>
</tr>
<tr>
<td>  30  </td>
<td>40   </td>
<p><tD>black</td>
</tr>
<tr>
<td>  31  </td>
<td>41   </td>
<p><tD>red</td>
</tr>
<tr>
<td>  32  </td>
<td>42   </td>
<td>green</td>
</tr>
<tr>
<td>  33  </td>
<td>43   </tD>
<td>yellow</td>
</tr>
<tr>
<td>  34  </td>
<td>44   </td>
<td>blue</td>
</tr>
<tr>
<td>  35  </td>
<td>45   </td>
<td>magenta</td>
</tr>
<tr>
<td>  36  </td>
<td>46   </td>
<td>cyan</td>
</tr>
<tr>
<td>  37  </td>
<td>47   </td>
<td>white</td>
</tr>
</table>
<p><b>Note</b><br />
This only works on ANSI terminals</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 = "aHR0cDovL3BhcmlvLm5vLzIwMDgvMDkvMDMvdGFpbC1mLXdpdGgtaGlnaGxpZ2h0Lzx3cHRiPiYjODIxNjt0YWlsIC1mJiM4MjE3OyB3aXRoIGhpZ2hsaWdodDx3cHRiPmh0dHA6Ly9wYXJpby5ubzx3cHRiPlBhcmlvIFRlY2hub0Jsb2I%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2008/09/03/tail-f-with-highlight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Script to customize a linux install</title>
		<link>http://pario.no/2008/02/20/script-to-customize-a-linux-install/</link>
		<comments>http://pario.no/2008/02/20/script-to-customize-a-linux-install/#comments</comments>
		<pubDate>Wed, 20 Feb 2008 20:59:19 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[RedHat]]></category>

		<guid isPermaLink="false">http://pario.no/2008/02/20/script-to-customize-a-linux-install/</guid>
		<description><![CDATA[This is a simple bash script I whipped together to make som custom changes on our linux installations, it can be used as a kickstart post-configuration file for RedHat RHEL4 and RHEL5 installations. #!/bin/bash # Enable daily updates of the locate database perl -pi -e 's/DAILY_UPDATE=no/DAILY_UPDATE=yes/' /etc/updatedb.conf # Customize login banners echo "Authorized users only. [...]]]></description>
			<content:encoded><![CDATA[<p>This is a simple bash script I whipped together to make som custom changes on our linux installations, it can be used as a kickstart post-configuration file for RedHat RHEL4 and RHEL5 installations.</p>
<pre>
#!/bin/bash

# Enable daily updates of the locate database
perl -pi -e 's/DAILY_UPDATE=no/DAILY_UPDATE=yes/' /etc/updatedb.conf

# Customize login banners
echo "Authorized users only.  All activity may be monitored and reported" &gt;&gt; /etc/motd
echo "Authorized users only.  All activity may be monitored and reported" &gt;&gt; /etc/issue.net

# Disable SELinux (this should be changed back when any problems with it has been fixed)
#perl -pi -e 's/^SELINUX=.*$/SELINUX=Disabled/' /etc/selinux/config

# Configure tcp wrappers host access to allow only ssh access
cat &lt;<eof>&gt; /etc/hosts.allow
ALL:localhost
sshd:ALL
EOF
cat &lt;<eof>&gt; /etc/hosts.deny
ALL:ALL
EOF</eof></eof></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 = "aHR0cDovL3BhcmlvLm5vLzIwMDgvMDIvMjAvc2NyaXB0LXRvLWN1c3RvbWl6ZS1hLWxpbnV4LWluc3RhbGwvPHdwdGI%2BU2NyaXB0IHRvIGN1c3RvbWl6ZSBhIGxpbnV4IGluc3RhbGw8d3B0Yj5odHRwOi8vcGFyaW8ubm88d3B0Yj5QYXJpbyBUZWNobm9CbG9i";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2008/02/20/script-to-customize-a-linux-install/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Determine false positive from rkhunter</title>
		<link>http://pario.no/2007/12/18/determine-false-positive-from-rkhunter/</link>
		<comments>http://pario.no/2007/12/18/determine-false-positive-from-rkhunter/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 07:02:49 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[ar]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[chattr]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[gutsy gibbons]]></category>
		<category><![CDATA[lsattr]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[rkhunter]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://pario.no/2007/12/18/determine-false-positive-from-rkhunter/</guid>
		<description><![CDATA[I&#8217;ve installed rkhunter, a rootkit checking script, on a Ubuntu 7.10 (Gutsy Gibbons) distro and today it mailed a message saying that 3 files had their properties changed. The files were /usr/bin/chattr, /usr/bin/lsattr and /usr/bin/perl Before doing anything I tried to update rkhunter to see if there had been any updates to fix this message rkhunter [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve installed <strong>rkhunter</strong>, a rootkit checking script, on a Ubuntu 7.10 (Gutsy Gibbons) distro and today it mailed a message saying that 3 files had their properties changed. The files were <strong>/usr/bin/chattr</strong>, <strong>/usr/bin/lsattr</strong> and <strong>/usr/bin/perl</strong><br />
Before doing anything I tried to update rkhunter to see if there had been any updates to fix this message <code>rkhunter --update</code> but the files were still giving a error warning. Since I haven&#8217;t used Debian/Ubuntu systems much I had to find a way to determine if these files had been tampered with. If this had been a RedHat system I would have run the command <code>rpm -V packagename</code> to verify if a package has been tampered with.</p>
<p>I found the package list at <a href="http://packages.ubuntu.com">http://packages.ubuntu.com</a> and entered the program paths I&#8217;ve shown above in the &#8220;Search the contents of packages&#8221; search box. The result after the search for <strong>/usr/bin/chattr</strong>, <strong>/usr/bin/lsattr</strong> and <strong>/usr/bin/perl</strong></p>
<ul>
<li>/usr/bin/chattr was in the package base/e2fsprogs</li>
<li>/usr/bin/lsattr was in the package base/e2fsprogs</li>
<li>/usr/bin/perl was in the package base/perl-base</li>
</ul>
<p>Downloaded the packages from the same website and verified the downloads using md5sum and then used the <strong>ar</strong> command to unpack/extract the files.</p>
<pre>
ar -x *.deb</pre>
<p>This will give two tarballs control.tar.gz and data.tar.gz. The first is the information dpkg needs to do a proper installation and configuration of the package, the second contains the binaries and data files.</p>
<p>When I extracted the tarball named <strong>data.tar.gz</strong> and wrote a little script using <strong>md5sum</strong> on each of the files to determine that all files were valid with the correct size, sum etc.</p>
<p><strong>The md5sum script</strong></p>
<pre>
#!/bin/bash
# This script have to be run from the path you extracted the debian package

for FILE in " /usr/bin/chattr /usr/bin/lsattr /usr/bin/perl usr/bin/chattr usr/bin/lsattr usr/bin/perl"
do
        md5sum $FILE &gt; md5sums.txt
done
echo If this number is larger than the amount of files compared, then something is fishy
echo `awk -F " " '{ print $1 }'&lt; md5sums.txt | sort | uniq | wc -l`</pre>
<p>Luckily my system files had the same md5sum as the files extracted from the downloaded package. This proves that my system was not compromised, at least not these files anyway.</p>
<p>The script can be <a href="http://pario.no/wp-content/uploads/2007/12/md5.sh" title="md5.sh">downloaded here</a></p>
<p><strong>The error message from rkhunter</strong></p>
<pre>
Warning: The file properties have changed:
         File: /usr/bin/chattr
         Current hash: 4703e5adba10128a0abbc036cefae73f754db142
         Stored hash : 2502e2f117415f56cd64568b042a91dd3ef79b80
         Current inode: 1735115    Stored inode: 1733967
         Current size: 7228    Stored size: 7296
         Current file modification time: 1197053992
         Stored file modification time : 1189103575
Warning: The file properties have changed:
         File: /usr/bin/lsattr
         Current hash: c3eba9c1952ccf894f8f71b999b081fe5ad5f4de
         Stored hash : 4ba9ee6cb8455509347059f7917ef7ed4bab6891
         Current inode: 1735124    Stored inode: 1734372
         Current size: 6000    Stored size: 6068
         Current file modification time: 1197053992
         Stored file modification time : 1189103575
Warning: The file properties have changed:
         File: /usr/bin/perl
         Current hash: 9c4d220d96fbaf9aaedbe4e034a767e8d510d7f6
         Stored hash : 155faff21807a6ad3687806ba7737223cd56ac68
         Current inode: 1733338    Stored inode: 1733472
         Current size: 1078128    Stored size: 1078160
         Current file modification time: 1196759924
         Stored file modification time : 1191046830</pre>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/packages.ubuntu.com"];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDcvMTIvMTgvZGV0ZXJtaW5lLWZhbHNlLXBvc2l0aXZlLWZyb20tcmtodW50ZXIvPHdwdGI%2BRGV0ZXJtaW5lIGZhbHNlIHBvc2l0aXZlIGZyb20gcmtodW50ZXI8d3B0Yj5odHRwOi8vcGFyaW8ubm88d3B0Yj5QYXJpbyBUZWNobm9CbG9i";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2007/12/18/determine-false-positive-from-rkhunter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Set photo filedate and time according to EXIF info</title>
		<link>http://pario.no/2007/12/05/set-photo-filedate-and-time-according-to-exif-info/</link>
		<comments>http://pario.no/2007/12/05/set-photo-filedate-and-time-according-to-exif-info/#comments</comments>
		<pubDate>Wed, 05 Dec 2007 12:36:49 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Photo etc]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[exiftool]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://pario.no/2007/12/05/set-photo-filedate-and-time-according-to-exif-info/</guid>
		<description><![CDATA[Sometimes a image files creation date is wrong and have to be corrected. This is a script I use to set a files creation date to the photos date retrieved from EXIF tags. The exiftool program should be available to run this script. #!/usr/bin/env perl use strict; $&#124;++; use Image::ExifTool qw(ImageInfo); use Time::Local; for my [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes a image files creation date is wrong and have to be corrected. This is a script I use to set a files creation date to the photos date retrieved from EXIF tags. The exiftool program should be available to run this script. </p>
<pre>
#!/usr/bin/env perl
use strict;
$|++;

use Image::ExifTool qw(ImageInfo);

use Time::Local;

for my $file (@ARGV) {
my $ii = ImageInfo($file, qw(DateTimeOriginal DateTime))
or warn("Skipping $file\n"), next;
my ($created) =
grep /\S/, @$ii{qw(DateTimeOriginal DateTime)};
next unless $created;
warn "using $created for $file\n";
if ($created =~ s/([-+ ])(\d\d):(\d\d)$//) {
my ($sign, $hour, $minute) = ($1, $2, $3);
# warn "ignoring offset of $sign $hour:$minute\n";
}
my @digits = $created =~ /(\d+)/g or next;
if ($digits[0] &lt; 1900) {
warn "bad year $digits[0] for $file";
next;
}
$digits[0] -= 1900;
$digits[1] -= 1;
my $gmtime = timegm(reverse @digits);
if ($gmtime &gt; time or $gmtime &lt; time - 86400*90) {
warn "preposterous gmtime for $file: ", scalar gmtime $gmtime;
# next;
}
utime($gmtime, $gmtime, $file) or warn "Cannot utime on $file: $!";
}</pre>
<p>Save it as datebyexif.pl</p>
<p>Usage:<br />
<code><br />
./datebyexif.pl *.JPG</code></p>
<p><a href="http://pario.no/wp-content/uploads/2007/12/datebyexif.pl" title="datebyexif.pl">Download the datebyexif.pl script</a></p>
<p>Source: <a href="http://www.macosxhints.com/comment.php?mode=view&amp;cid=83366">http://www.macosxhints.com/comment.php?mode=view&amp;cid=83366</a></p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/www.macosxhints.com\/comment.php?mode=view&amp;cid=83366"];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDcvMTIvMDUvc2V0LXBob3RvLWZpbGVkYXRlLWFuZC10aW1lLWFjY29yZGluZy10by1leGlmLWluZm8vPHdwdGI%2BU2V0IHBob3RvIGZpbGVkYXRlIGFuZCB0aW1lIGFjY29yZGluZyB0byBFWElGIGluZm88d3B0Yj5odHRwOi8vcGFyaW8ubm88d3B0Yj5QYXJpbyBUZWNobm9CbG9i";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2007/12/05/set-photo-filedate-and-time-according-to-exif-info/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

