source: trunk/src/elogd.sh @ 85

Last change on this file since 85 was 85, checked in by pinsard, 14 years ago

better representation of variable parts in filenames

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1#! /bin/sh
2#+
3#
4# .. _elogd.sh:
5#
6# ========
7# elogd.sh
8# ========
9#
10# --------------------------------------------------------------------------
11# edit the most recent :file:`${IRCAAM_LOG}/{action}.log.{YYYYMMDDTHHMMSSZ}`
12# --------------------------------------------------------------------------
13#
14# SYNOPSIS
15# ========
16#
17# ::
18#
19#  $ elogd.sh action
20#
21#
22# DESCRIPTION
23# ===========
24#
25# ``elogd.sh`` launch ${EDITOR} on the most recent release of :file:`${IRCAAM_LOG}/{action}.log.{YYYYMMDDTHHMMSSZ}`.
26#
27#
28# SEE ALSO
29# ========
30#
31# :ref:`ircaam_profile.sh`
32#
33# :ref:`dlogd.sh`
34#
35# :ref:`plogd.sh`
36#
37# :ref:`tlogd.sh`
38#
39# EVOLUTIONS
40# ==========
41#
42# $Id$
43#
44# - fplod 20100226T151441Z aedon.locean-ipsl.upmc.fr (Darwin)
45#
46#   * replace ????-??-??T??:??:??Z by ????????T??????Z
47#
48# - fplod 2006-02-20T16:38:30Z aedon.lodyc.jussieu.fr (Darwin)
49#
50#   * posix
51#
52#-
53#
54set -u
55system=$(uname)
56case "${system}" in
57   AIX|IRIX64)
58      echo " www : no specific posix checking"
59   ;;
60   *)
61      set -o posix
62   ;;
63esac
64unset system
65#
66LANG=POSIX
67#
68command=$(basename ${0})
69#
70if [ ! "${EDITOR}" ]
71then
72   echo " ${command} : eee : EDITOR undefined" >&2
73   exit 1
74fi
75if [ "${1}" = "" ]
76then
77   echo "${command} : eee : 1st parameter missing" >&2
78   exit 1
79fi
80#
81# check for ${IRCAAM_LOG} definition
82if [ "${IRCAAM_LOG}" = "" ]
83then
84   echo " eee : \${IRCAAM_LOG} not defined"
85   exit 1
86fi
87#
88# check for ${IRCAAM_LOG} existence
89if [ ! -d ${IRCAAM_LOG} ]
90then
91   echo " eee : ${IRCAAM_LOG} not found"
92   exit 1
93fi
94#
95# check for permission access on IRCAAM_LOG
96if [ ! -x ${IRCAAM_LOG} ]
97then
98   echo " eee : ${IRCAAM_LOG} not reachable"
99   exit 1
100fi
101#
102log=$(find ${IRCAAM_LOG} -name "${1}.log.????????T??????Z" | sort | \
103tail -n 1)
104tmp=${?}
105if [ ${tmp} -eq 0 ]
106then
107   if [ "${log}" = "" ]
108   then
109      echo "${command} : eee : no release of ${IRCAAM_LOG}/${1}.log" >&2
110      exit 1
111   else
112      # edit
113      ${EDITOR} ${log}
114      exit 0
115   fi
116else
117   exit 1
118fi
Note: See TracBrowser for help on using the repository browser.