Posts

Showing posts from August, 2008

Console Beep On Error Line of a Log File

Ok folks , this is non-java :) Today I had to watch a log file and alert some ppl when an error phrase seen on log file. This is a terrible jıb todo. First I run on my linux server: #tail -f mylogfile | grep ERRORSTRING this worked but put me in front of the screen. Why not my console beep when ERRORSTRING exists in the log file ? I need an application to beep when read a line from stdin. This is piece of cake in java but i did not want to load JVM for this purpose because of memory needs. So I warped to good old days and decided to write a C program to do this job. #include <stdio.h> #include <string.h> #include <stdlib.h> int main(int argc, char *argv[]) { char buf[1024]; int n; while (fgets(buf, sizeof buf, stdin) != NULL) { n = strlen(buf); if (n > 0 && buf[n-1] == '\n') { printf("\a"); printf("%s\n", buf);