May 212012
 

Last night I looked at a few bash scripts that were a bit ugly. Each of them did more or less the same just used a different array. So I ended up merging them. The little issue I run into was that the used array name was passed as an argument to the script.

The solution was fairly easy by using indirect shell expansion, the important bit is the “!” in front of the variable c.

Below a simple example:

#!/bin/bash

a1=(a b c); 
a2=(x y z); 

while getopts "p:" OPT; do
    case $OPT in 
        p) parameter=${OPTARG};;
    esac
done

c="${parameter}[*]"; 

for i in ${!c}; do
     echo ${i};
done
May 022012
 

Had to look up the outgoing IP from a server today. To my surprise the usual curl request to http://whatismyipaddress.com/  failed with the following:

[@sphere: ~]$ curl "http://whatismyipaddress.com/"
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <html><head>
 <title>403 Forbidden</title>
 </head><body>
 <h1>Forbidden</h1>
 <p>You don't have permission to access /
 on this server.</p>
 <p>Additionally, a 500 Internal Server Error
 error was encountered while trying to use an ErrorDocument to handle the request.</p>
 </body></html>

Didn’t expect a plain curl would cause a 500. 🙂

So I ended up with the follwing small CGI script, which output can be seen under ip.ps-xaf.de

#!/usr/bin/perl -w
use CGI;
my $q = new CGI;
print $q->header;
print $q->remote_addr . "\n";
exit;

 
 

Jan 042012
 

It’s was time to replace my good old x40 with a more modern laptop. Having multiple tabs in Firefox/Thunderbird open and a few xterm made it a bit sluggish but still fully sufficient otherwise. So will keep using it  when some short trips are required.  As I wasn’t willing to spent big money I decided to get a x200 of luxnote. Price seemed reasonable, was supposed to be in a good condition and shop ratings were alright too. So my resume after 2 month, it still works – wouldn’t consider it as normal nowadays –  running it with Wheezy/sid and awesome as lightweight window manager.

Took some time to get awesome the way setup I wanted, as before fluxbox was my WM of choice and I still love it. But thought to give a different approach a go and haven’t regret it so far..