Trap Errors, Exit Codes and Line Numbers within a Bash script (and some output redirection, too)

Posted by: admin  :  Category: Programming, Scripting, Shells

A discussion today was about error handling in shell scripts, Bash in particular.
Well, we all know about the usual knitpicks about error handling and the possible consequences in not doing so properly 😉
Read more…

Recognize invalid/unexpected characters with Perl

Posted by: admin  :  Category: Perl

Today a colleague of mine faced a very weird problem.
While parsing XML output from an HP ILO into Perl, his code constantly broke with the message:

FILE.XML:123 parser error : PCDATA invalid Char value 1

While the message itself states clearly that there is an unexpected character value (Char value 1, ASCII SOH) on one hand, it doesn’t tell the character position on the other.
Read more…

Strange compilation error on MySQL

Posted by: admin  :  Category: FreeBSD, Programming

Yesterday I started digging around for a solution to create per-user or per-database statistics on MySQL, one of the more important peaces I was missing from it for a long time.

Luckily enough, some guys over there had already done some work on this topic, so I wouldn’t have to start over from scratch 🙂

Read more…

Apple’s Safari violates RFC2616

Posted by: admin  :  Category: Programming

Today I faced an issue, where HTTP redirections didn’t work out as expected on Apple’s Safari browser.

This came up while I was coding up some sort of web-based login redirector, which is stacked up in three layers:

  1. html login form
  2. login preprocessor (server side scripting)
  3. login processor (server side scripting)

This solution was required to implement a generic way to create branded login forms, which will send their login requests to a unique, centralized login preprocessor, which will – after doing some internal magic – redirect to the final login processor.
Read more…

No "sleep" command for batch files? Make it a choice!

Posted by: admin  :  Category: DOS, Scripting, Windows

I just trapped myself while hacking up a batch file.
Used to shell scripting I wanted to add a delay to the batch using “sleep”.

Dough! Bad Idea! Bad command or filename. Smash your head here to continue {(x)}!
Read more…

Your Makefile has been rebuilt…

Posted by: admin  :  Category: Perl

One might asume building a port from source should be fast and straight forward.
Not in this case, however…
Read more…

wipe out directory tree through rsync

Posted by: admin  :  Category: Bits and Bytes, Shells

To wipe out a directory tree on a rsync server (an export) which you don’t have shell access to (but proper write access of course), just use this command:

# rsync -av –delete /tmp/ rsync://

/tmp/ is an example for a local but empty directory (empty as in ‘mkdir /tmp/

Putting the slashes at the end of both local and remote path will allow you to sync the empty directory onto the server, effectively removing everything on the receiver side.

Prototype Mismatch in APR::XSLoader::BOOTSTRAP

Posted by: admin  :  Category: Perl

Well, today I just did not believe my eyes.

I was just bringing up a new webmail host when I noticed Apache throwing an 500 internal server error at me.
Read more…

Find And Replace Strings

Posted by: admin  :  Category: Perl, Shells

Imagine you have a directory with thousands of text files, each of which containing some keywords to be replaced.

While there’s a lot of tools out there allowing you to find and replace strings in text files, there’s always a goog reason to use the tools that you already have.

The following snippet uses find in combination with perl to achieve the task:
Read more…

Obscure Perl Module Compilation Error

Posted by: admin  :  Category: Perl

When I was setting up a development box today I encountered a strange error while compiling the Mail::ClamAV perl module.
Read more…