Let's see, can you use a shell script for that or does it need a C program?