<?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>SKYCUBE.net &#187; Linux</title>
	<atom:link href="http://skycube.net/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://skycube.net</link>
	<description>Projects, References and Personals by Per Lasse Baasch</description>
	<lastBuildDate>Wed, 14 Mar 2012 23:43:51 +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>Rename files via shell-script</title>
		<link>http://skycube.net/2009/10/28/rename-files-via-shell-script/</link>
		<comments>http://skycube.net/2009/10/28/rename-files-via-shell-script/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 20:13:08 +0000</pubDate>
		<dc:creator>Per Lasse Baasch</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.skycube.net/?p=131</guid>
		<description><![CDATA[In order to a miss configuration I had for a long time the problem with hundreds of files which had a crap name. Tonight I had the time to solve this: Preamble: -rw------- 1 apache root 273K 24. Jul 15:37 UPLOAD_PATH1 -rw-r--r-- 1 apache root 275K 24. Jul 15:37 UPLOAD_PATH10 -rw-r--r-- 1 apache root 220K [...]]]></description>
			<content:encoded><![CDATA[<p>In order to a miss configuration I had for a long time the problem with hundreds of<br />
files which had a crap name. Tonight I had the time to solve this:</p>
<p><strong>Preamble:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #660033;">-rw-------</span> <span style="color: #000000;">1</span> apache root 273K <span style="color: #000000;">24</span>. Jul <span style="color: #000000;">15</span>:<span style="color: #000000;">37</span> UPLOAD_PATH1
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> apache root 275K <span style="color: #000000;">24</span>. Jul <span style="color: #000000;">15</span>:<span style="color: #000000;">37</span> UPLOAD_PATH10
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> apache root 220K <span style="color: #000000;">19</span>. Okt <span style="color: #000000;">15</span>:<span style="color: #000000;">14</span> UPLOAD_PATH11
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> apache root <span style="color: #000000;">3</span>,1M <span style="color: #000000;">19</span>. Okt <span style="color: #000000;">15</span>:<span style="color: #000000;">17</span> UPLOAD_PATH12
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> apache root 241K <span style="color: #000000;">19</span>. Okt <span style="color: #000000;">16</span>:<span style="color: #000000;">13</span> UPLOAD_PATH13
<span style="color: #660033;">-rw-------</span> <span style="color: #000000;">1</span> apache root  60K <span style="color: #000000;">24</span>. Jul <span style="color: #000000;">15</span>:<span style="color: #000000;">37</span> UPLOAD_PATH2
<span style="color: #660033;">-rw-------</span> <span style="color: #000000;">1</span> apache root 105K <span style="color: #000000;">24</span>. Jul <span style="color: #000000;">15</span>:<span style="color: #000000;">37</span> UPLOAD_PATH3
<span style="color: #660033;">-rw-------</span> <span style="color: #000000;">1</span> apache root  60K <span style="color: #000000;">24</span>. Jul <span style="color: #000000;">15</span>:<span style="color: #000000;">37</span> UPLOAD_PATH4
<span style="color: #660033;">-rw-------</span> <span style="color: #000000;">1</span> apache root  60K <span style="color: #000000;">24</span>. Jul <span style="color: #000000;">15</span>:<span style="color: #000000;">37</span> UPLOAD_PATH5
<span style="color: #660033;">-rw-------</span> <span style="color: #000000;">1</span> apache root  60K <span style="color: #000000;">24</span>. Jul <span style="color: #000000;">15</span>:<span style="color: #000000;">37</span> UPLOAD_PATH6
<span style="color: #660033;">-rw-------</span> <span style="color: #000000;">1</span> apache root  60K <span style="color: #000000;">24</span>. Jul <span style="color: #000000;">15</span>:<span style="color: #000000;">37</span> UPLOAD_PATH7
<span style="color: #660033;">-rw-------</span> <span style="color: #000000;">1</span> apache root  60K <span style="color: #000000;">24</span>. Jul <span style="color: #000000;">15</span>:<span style="color: #000000;">37</span> UPLOAD_PATH8
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> apache root 273K <span style="color: #000000;">24</span>. Jul <span style="color: #000000;">15</span>:<span style="color: #000000;">37</span> UPLOAD_PATH9</pre></div></div>

<p>The way to rename them is pretty simple with a bash script, but the notation/ syntax<br />
is just a little bit tricky.<br />
While searching with google, I&#8217;d found several scripts but no simple solution.<br />
My solution just executes a <em>ls</em> command, push the output in an array, and the builds a new name using <em>sed</em>.<br />
After this steps, the new name is ready to use with a simple <em>mv</em> command.</p>
<p><strong>Solution via bash:</strong></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: #007800;">list</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">for</span> filename <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${list[@]}</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #007800;">myvar</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$filename</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/UPLOAD_PATH//g'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #666666; font-style: italic;">#echo 'mv '$filename' '$myvar</span>
  <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$filename</span> <span style="color: #007800;">$myvar</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://skycube.net/2009/10/28/rename-files-via-shell-script/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Rename photos by EXIF Timestamp, Date</title>
		<link>http://skycube.net/2009/09/26/rename-photos-by-exif-timestamp-date/</link>
		<comments>http://skycube.net/2009/09/26/rename-photos-by-exif-timestamp-date/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 18:55:18 +0000</pubDate>
		<dc:creator>Per Lasse Baasch</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Photo]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Photographie]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.skycube.net/?p=123</guid>
		<description><![CDATA[Something beside the usually blog entries&#8230; After the my last surf holidays in September 2009 I had a problem with my two cameras&#8230; Sony Alpha 200 and Pentax Option W60. Both got different filenamings and right now I&#8217;ve never seen a camera where you can fully design the filename format. While I worked with windows, [...]]]></description>
			<content:encoded><![CDATA[<p>Something beside the usually blog entries&#8230;</p>
<p>After the my last surf holidays in September 2009 I had a problem with my two cameras&#8230; Sony Alpha 200 and Pentax Option W60. Both got different filenamings and right now I&#8217;ve never seen a camera where you can fully design the filename format.<br />
While I worked with windows, years ago, I used a app named &#8216;Joe&#8217;,.. but port a windows app to Linux.. no thanks <img src='http://skycube.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
The name of (one) solution is exiv2!</p>
<p><strong>Installing exiv2 on debian based systems:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> update
<span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> exiv2</pre></div></div>

<p><strong>Renaming:</strong><br />
Launch a terminal, go to the dir where the photos are located</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>per<span style="color: #000000; font-weight: bold;">/</span>Documents<span style="color: #000000; font-weight: bold;">/</span>Portugal2009</pre></div></div>

<p><strong>Rename them:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">exiv2 <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">&quot;%Y-%m-%d_%H:%M:%S_My_Name&quot;</span> <span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

<p><strong>Before:</strong>	<em>IMGP0078.JPG</em><br />
<strong>After:</strong>	<em>2009-09-03_16:54:42_My_Name.JPG</em></p>
]]></content:encoded>
			<wfw:commentRss>http://skycube.net/2009/09/26/rename-photos-by-exif-timestamp-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Restricetd access to a web-application with htaccess or php</title>
		<link>http://skycube.net/2009/07/03/restricetd-access-to-a-web-application-with-htaccess-or-php/</link>
		<comments>http://skycube.net/2009/07/03/restricetd-access-to-a-web-application-with-htaccess-or-php/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 19:08:17 +0000</pubDate>
		<dc:creator>Per Lasse Baasch</dc:creator>
				<category><![CDATA[other]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.skycube.net/?p=96</guid>
		<description><![CDATA[If you building a simple web-application and you are not really sure, ow secure are the authentication and or the rest of the application you should think about to limit the access to the application. Furthermore, may your application should be available only for testing purpose of several customers the following could help you: First [...]]]></description>
			<content:encoded><![CDATA[<p>If you building a simple web-application and you are not really sure, ow secure are the authentication and or the rest of the application you should think about to limit the access to the application.<br />
Furthermore, may your application should be available only for testing purpose of several customers the following could help you:</p>
<p><strong>First way</strong>&#8230; using a <em>.htaccess</em> which controls the access using a apache web server.<br />
This is a very fast sollution <strong>BUT you CAN&#8217;T use</strong> <strong>hostnames</strong> and or full qualified <strong>dns names</strong> like skycube.net or yourname.dyndns.org</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>Limit GET HEAD POST<span style="color: #000000; font-weight: bold;">&gt;</span>
order deny,allow
allow from 62.75.185.219
allow from 127.0.1.1
allow from 127.0.0.1
deny from all
<span style="color: #000000; font-weight: bold;">&lt;/</span>Limit<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<hr style="margin: 10px;" />
<p><strong>The second way</strong>&#8230; which I prefer, using a php code snippet. This allows you to <strong>use hostnames and full qualified domain names</strong>. Definitely you can write it in less than the lines I used below for the code, but in of understanding what the code does, it&#8217;s better <img src='http://skycube.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * ACL array
 */</span>
<span style="color: #000088;">$valid_hosts</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$valid_hosts</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$valid_hosts</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'127.0.0.1'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$valid_hosts</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'127.0.1.1'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$valid_hosts</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'yourname.dyndns.org'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$valid_hosts</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'skycube.net'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span>sizeof<span style="color: #009900;">&#40;</span><span style="color: #000088;">$valid_hosts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$valid_ip</span> <span style="color: #339933;">=</span> <span style="color: #990000;">gethostbyname</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$valid_hosts</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$valid_ip</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$valid_state</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'valid'</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$valid_state</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'invalid'</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$valid_state</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'valid'</span><span style="color: #009900;">&#41;</span>
  <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: http://www.skycube.net&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://skycube.net/2009/07/03/restricetd-access-to-a-web-application-with-htaccess-or-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Google Earth 5.0 (beta) on Ubuntu 8.10</title>
		<link>http://skycube.net/2009/03/06/google-earth-50-beta-on-ubuntu-810/</link>
		<comments>http://skycube.net/2009/03/06/google-earth-50-beta-on-ubuntu-810/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 23:04:13 +0000</pubDate>
		<dc:creator>Per Lasse Baasch</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.skycube.net/?p=47</guid>
		<description><![CDATA[Today I tried to install the (new) version of Google Earth 5.0 (beta), cause some one told me about new Streetview pics in town.. After I installed the app, I just tried to run,.. Saw the splash and then everything closes.. What happened.. I started the program in a shell and there is the problem: [...]]]></description>
			<content:encoded><![CDATA[<p>Today I tried to install the (new) version of <strong>Google Earth 5.0 (beta)</strong>, cause some one told me about new Streetview pics in town..</p>
<p>After I installed the app, I just tried to run,.. Saw the splash and then everything closes..<br />
What happened..</p>
<p>I started the program in a shell and there is the problem:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Installing desktop icon...
Warning: Unable to create prefs directory <span style="color: #ff0000;">'/home/pbaasch/.googleearth'</span>. File exists.
.<span style="color: #000000; font-weight: bold;">/</span>googleearth-bin: relocation error: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>i686<span style="color: #000000; font-weight: bold;">/</span>cmov<span style="color: #000000; font-weight: bold;">/</span>libssl.so.0.9.8: symbol BIO_test_flags, version OPENSSL_0.9.8 not defined <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #c20cb9; font-weight: bold;">file</span> libcrypto.so.0.9.8 with <span style="color: #c20cb9; font-weight: bold;">link</span> <span style="color: #000000; font-weight: bold;">time</span> reference</pre></div></div>

<p>The sollution is very simple, just a workaround, but it works:</p>
<p>Find the file <code><strong>libcrypto.so.0.9.8</strong> and just <em><strong>rename</strong></em> or <em><strong>delete</strong></em> it...</code></p>
]]></content:encoded>
			<wfw:commentRss>http://skycube.net/2009/03/06/google-earth-50-beta-on-ubuntu-810/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Session problems</title>
		<link>http://skycube.net/2009/02/21/session-problems/</link>
		<comments>http://skycube.net/2009/02/21/session-problems/#comments</comments>
		<pubDate>Sat, 21 Feb 2009 01:20:54 +0000</pubDate>
		<dc:creator>Per Lasse Baasch</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.skycube.net/?p=40</guid>
		<description><![CDATA[While you working with web applications it could happen that you get several errors.. Never underestimate real server problems. When you try to start a new Web 2.0 application or just the usage and/or visits of your application increase, maybe non-linear, you can login to your application but you can&#8217;t proceed. On enterprise applications it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>While you working with web applications it could happen that you get several errors.. Never underestimate real server problems. When you try to start a new <strong>Web 2.0</strong> application or just the usage and/or visits of your application increase, maybe non-linear, you can login to your application but you can&#8217;t proceed.</p>
<p>On enterprise applications it&#8217;s recommended to set <strong><em>php display errors to off</em></strong>, so won&#8217;t see what really happened.</p>
<p>While tracking the problem to your browser and the customers and may the service provider, you should just login with a shell.<br />
First thing you should do is, like all time, who and last. After that, may you try to find out what happen in the apache access and error log. You will find nothing, cause there is nothing critical, nothing new. May you see the session file in your filesystem, but why is it empty? A php bug?</p>
<p>Why? Ok just the answer, try this: <strong><em>df -h</em></strong> , you will see the a 100% full partition <img src='http://skycube.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   and when you try a <strong><em>du -shm /var/log/*</em></strong> you see your problem&#8230; GB&#8217;s of apache logs&#8230;</p>
<p>What happened? Your Web 2.0 application uses <strong>polling</strong>, and your apache got a custom, combined log which writes to access.log.</p>
<ul>
<li> Solution 1: Drop the line in your apache virtualhost configuration for custom, combined log</li>
</ul>
<ul>
<li> Solution 2: Proceed a massive logrotation</li>
</ul>
<ul>
<li> Solution 3: Pipe the combined  log to a perl or php-cli script which filters the polling events (I prefer)</li>
</ul>
<p>On local, staging and or development installations you should switch the display errors for php to on,&#8230; then you get messages like this:<br />
<code><br />
WARNING: session_write_close() [function.session-write-close]...<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://skycube.net/2009/02/21/session-problems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

