G
George Monappallil
Hi Guys:
Below is my code.
How can I grab the last data of the first column of the output of egrep -n
and store it in a file for comparing it against the last data next time the
script is run.
Is there an easier way of doing this?
Your help is appreciated.
------------------------------
#!/bin/perl
$LOG = "./messages.log";
$SIG{"INT"} = "clean_exit";
$SIG{"TERM"} = "clean_exit";
open(FILE, $LOG) || die "Can not open file $LOG";
# Main loop.
$WORD = "ERROR";
if ($LOG) {
$CURRLINECNT=`egrep -n $WORD $LOG | awk -F":" '{print $1}'`;
# THIS DOES NOT WORK EITHER. What's wrong in the syntax ?
}
# We jump here in case of INT or TERM signals
sub clean_exit {
($signal) = @_;
close FILE;
print "$file closed.\nExiting on signal $signal...\n";
exit;
}
--------------------------
Below is my code.
How can I grab the last data of the first column of the output of egrep -n
and store it in a file for comparing it against the last data next time the
script is run.
Is there an easier way of doing this?
Your help is appreciated.
------------------------------
#!/bin/perl
$LOG = "./messages.log";
$SIG{"INT"} = "clean_exit";
$SIG{"TERM"} = "clean_exit";
open(FILE, $LOG) || die "Can not open file $LOG";
# Main loop.
$WORD = "ERROR";
if ($LOG) {
$CURRLINECNT=`egrep -n $WORD $LOG | awk -F":" '{print $1}'`;
# THIS DOES NOT WORK EITHER. What's wrong in the syntax ?
}
# We jump here in case of INT or TERM signals
sub clean_exit {
($signal) = @_;
close FILE;
print "$file closed.\nExiting on signal $signal...\n";
exit;
}
--------------------------