And I forgot to include the code of my script :-(

---BEGIN OF SCRIPT ---
#! /usr/bin/ksh
###############
# svclog
#
# Syntax : svclog [-l num] [-n] fmri
#             -l num : Show last num lines
#             -n     : Show only logfile name
#
# Purpose : Show log file of Service (FMRI)
#
#

#################
### Set variables
###
SVCPROP="/usr/bin/svcprop -p restarter/logfile"
PAGER=${PAGER:-/usr/bin/more}
TAIL="/usr/bin/tail"

###################
### Process options
###
count=0
printname=0
while getopts :l:n option ; do
        case $option in
                l) count=$OPTARG
                        ;;
                n) printname=1
                        ;;
        esac
done
shift $OPTIND-1

############
### Check $1
###
if [ $# -ne 1 ] ; then
        print "Usage: $(basename $0) fmri" >&2
        exit 2
fi
FMRI=$1

###########################
### Get log file of service
###
LOGFILE=$(${SVCPROP} ${FMRI})

###########################
### Check existence logfile
###
if [ "$printname" -eq 1 ] ; then
        print "${LOGFILE}"
        print "${LOGFILE}"

elif [ -r ${LOGFILE} ] ; then
        if [ $count -eq 0 ] ; then
                ${PAGER} ${LOGFILE}

        else
                ${TAIL} -$count ${LOGFILE}
        fi

else
        if [ ! -e ${LOGFILE} ] ; then
                print "${LOGFILE} not found" >&2
                exit 3

        elif [ ! -r ${LOGFILE} ] ; then
                print "${LOGFILE} not readable" >&2
                exit 4
        fi
fi

### eos
--- END OF SCRIPT ---
 
 
This message posted from opensolaris.org

Reply via email to