I'll just put it out there now that I barely ever script anything and my knowledge of programming is only slightly above nothing...
That being said I'm currently writing a very simple script to pick out certain lines from a log file and save them to a separate file (filterout.log)
I wrote something for awk that works perfectly from the terminal (logtest.awk)
Code:
#!/usr/bin/awk -f
BEGIN {
FS=" "
outfile = "filterout.log"
}
$2 == "AC/BATT_PWR" { print substr ($0,10,30) >> outfile}
$2 == "COMM-FAULT" { print substr ($0,10,30) >> outfile}
Now if I run this script against my alarm.log file any lines with those two strings get written to filterout.log
My problem is that eventually I want to monitor alarm.log in real time using tail -f.
To test this I use the following command:
Code:
tail -f alarm.log | logtest.awk
Then manually append events to the alarm.log file by:
Code:
cat dummyevents.log >> alarm.log
This results in nothing being written to my filtered output file.
I'm stumped as to what's happening here, can anyone help me out?
Thanks
Bookmarks