Need help formatting script output. I dug up a watchfile.pl script on the net ( it was posted here as an alternative to Tripwire ) to monitor files/directories for changes.
It generates fairly consistent output. First, it builds a list of files you tell it to watch, which at the end of that list is:
------------------------------------------------
After the dashes, it will log updates. I will just send everything to standard out.
Mon Oct 20 12:02:17 2008: /tmp/dcfile001: Changed: uid ctime
-rw-r--r-- 1 billg system 6 Oct 20 12:01 /tmp/rtfile001
Mon Oct 20 12:02:17 2008: /tmp/downlist.tmp: Changed: size mtime ctime
-rw-r--r-- 1 root system 56 Oct 20 12:02 /tmp/downlist.tmp
Mon Oct 20 12:06:24 2008: /tmp/croutKYelH8: Changed: file deleted
Mon Oct 20 12:06:24 2008: /tmp/last_activated.tmp: Changed: size mtime ctime
-rw-r--r-- 1 root system 583 Oct 20 12:06 /tmp/last_activated.tmp
I want to have a script to parse this output nightly. The output is consistent ( except when file is deleted, you only get one line ). I'm trying to figure out how to parse this for feeding into Excel or MySQL with these fields:
DATE/TIME = Mon Oct 20 12:07:25 2008:
FILENAME = /tmp/xlogfile:
WHAT = Changed: mtime ctime
UPDATED = -rw-r--r-- 1 root system 3206 Oct 20 12:07 /tmp/xlogfile
How can I create those divisions and put it all on one line?
It generates fairly consistent output. First, it builds a list of files you tell it to watch, which at the end of that list is:
------------------------------------------------
After the dashes, it will log updates. I will just send everything to standard out.
Mon Oct 20 12:02:17 2008: /tmp/dcfile001: Changed: uid ctime
-rw-r--r-- 1 billg system 6 Oct 20 12:01 /tmp/rtfile001
Mon Oct 20 12:02:17 2008: /tmp/downlist.tmp: Changed: size mtime ctime
-rw-r--r-- 1 root system 56 Oct 20 12:02 /tmp/downlist.tmp
Mon Oct 20 12:06:24 2008: /tmp/croutKYelH8: Changed: file deleted
Mon Oct 20 12:06:24 2008: /tmp/last_activated.tmp: Changed: size mtime ctime
-rw-r--r-- 1 root system 583 Oct 20 12:06 /tmp/last_activated.tmp
I want to have a script to parse this output nightly. The output is consistent ( except when file is deleted, you only get one line ). I'm trying to figure out how to parse this for feeding into Excel or MySQL with these fields:
DATE/TIME = Mon Oct 20 12:07:25 2008:
FILENAME = /tmp/xlogfile:
WHAT = Changed: mtime ctime
UPDATED = -rw-r--r-- 1 root system 3206 Oct 20 12:07 /tmp/xlogfile
How can I create those divisions and put it all on one line?