May 22, 2010

Mass editing kettle transformations


Quickly wanted to share this. It ain't no rocket science, but it's pretty usefull.

This morning, I quickly needed to point 50 transformations at a new server. Since I didn't parametrize the hostname of the server I found myself with 50 transformations containing this:

rather than this:

Luckily all kettle transformations are human readable XML formatted text files. No proprietary format like some commercial venders prefer, but plain text.

So this little command solved my problems in milliseconds.

perl -pi -w -e 's/10\.89\.0\.191/\$\{HOSTNAME\}/g;' *.ktr
-e means execute the following line of code.
-i means edit in-place
-w write warnings
-p loop

Next thing to do is just making sure that ${HOSTNAME} is added to the file and all worries are over.

With thanks to ...