#! /bin/sh
#
#+
#
# NAME
# ====
#
# plogd.sh - prints the most recent release of ${IRCAAM_LOG}/action.log.YYYY-MM-DDTHH:MM:SSZ
#
# SYNOPSIS
# ========
#
# ::
#
#  $ plogd.sh action
#
#
# DESCRIPTION
# ===========
#
# ``plogd.sh`` prints the most recent release of ${IRCAAM_LOG}/action.log.YYYY-MM-DDTHH:MM:SSZ.
#
#
# It uses a2ps application.
#
# Print is one on the default printer.
#
# SEE ALSO
# ========
# 
# ircaam_profile.sh_
# 
# .. _ircaam_profile.sh : ircaam_profile.sh.html
#
# dlogd.sh_
# 
# .. _dlogd.sh : dlogd.sh.html
#
# elogd.sh_
# 
# .. _elogd.sh : elogd.sh.html
#
# tlogd.sh_
# 
# .. _tlogd.sh : tlogd.sh.html
#
# FILES
# =====
#
# original location
# ~~~~~~~~~~~~~~~~~
#
# /usr/home/fplod/incas/ircaam/ircaam_ws/src/plogd.sh sur cerbere.locean-ipsl.upmc.fr
#
# EVOLUTIONS
# ==========
#
# $Id$
#
# - fplod 2006-02-20T16:15:35Z aedon.lodyc.jussieu.fr (Darwin)
#
#   * posix
#
#-
#
set -u
system=$(uname)
case "${system}" in
AIX|IRIX64)
  echo " www : no specific posix checking"
;;
*)
  set -o posix
;;
esac
#
command=$(basename ${0})
#
if [ "${1}" = "" ]
then
 echo "${command} : eee : 1st parameter missing" >&2
 exit 1
fi
# test if a2ps available
tool=a2ps
type ${tool} 1> /dev/null 2>&1
status=${?}
if [ ${status} -ne 0 ]
then
 echo "${command} : eee : ${tool} unavailable" >&2
 exit 4
fi
unset tool
unset status
#
systeme=`uname`
#
log=$(find ${IRCAAM_LOG} -name "${1}.log.????-??-??T??:??:??Z" | sort | \
tail -n 1)
tmp=${?}
if [ ${tmp} -eq 0 ]
then
 if [ "${log}" = "" ]
 then
  echo "${command} : eee : no release of ${IRCAAM_LOG}/${1}.log" >&2
  exit 1
 else
  # printing 
  a2ps --print-anyway=1 ${log}
  exit 0
 fi
else
 exit 1
fi
