Current File : //root/panel/modules/tomcatlogviewer/code/get_logs.sh
#!/bin/bash
temp_filename=$1
from_line=$2
to_line=$3
for entry in /usr/local/*
do
    if [[ $entry = *"tomcat"* ]]
    then
        TOMCAT_PATH=$entry
    fi
done

LOG_PATH=$TOMCAT_PATH"/logs/catalina.out"

if [ -z $from_line ]
then
    from_line=`wc -l $LOG_PATH | cut -d ' ' -f1`
    to_line=`expr $from_line - 100`
fi
chown apache:apache $temp_filename
awk "NR >= $to_line && NR <= $from_line" $LOG_PATH > $temp_filename
form_to_line=$from_line" "$to_line
echo $form_to_line