xref: /onnv-gate/usr/src/cmd/bnu/uulog (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!/bin/sh
2*0Sstevel@tonic-gate#
3*0Sstevel@tonic-gate# CDDL HEADER START
4*0Sstevel@tonic-gate#
5*0Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*0Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only
7*0Sstevel@tonic-gate# (the "License").  You may not use this file except in compliance
8*0Sstevel@tonic-gate# with the License.
9*0Sstevel@tonic-gate#
10*0Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11*0Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
12*0Sstevel@tonic-gate# See the License for the specific language governing permissions
13*0Sstevel@tonic-gate# and limitations under the License.
14*0Sstevel@tonic-gate#
15*0Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
16*0Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17*0Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
18*0Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
19*0Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
20*0Sstevel@tonic-gate#
21*0Sstevel@tonic-gate# CDDL HEADER END
22*0Sstevel@tonic-gate#
23*0Sstevel@tonic-gate#
24*0Sstevel@tonic-gate# Copyright 1995 Sun Microsystems, Inc.  All rights reserved.
25*0Sstevel@tonic-gate# Use is subject to license terms.
26*0Sstevel@tonic-gate#
27*0Sstevel@tonic-gate#ident	"%Z%%M%	%I%	%E% SMI"
28*0Sstevel@tonic-gateexport IFS PATH
29*0Sstevel@tonic-gateIFS="
30*0Sstevel@tonic-gate"
31*0Sstevel@tonic-gatePATH="/usr/bin"
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gate#
34*0Sstevel@tonic-gate# usage:
35*0Sstevel@tonic-gate# 	uulog
36*0Sstevel@tonic-gate# or	uulog foo
37*0Sstevel@tonic-gate# or	uulog -sfoo
38*0Sstevel@tonic-gate# or	uulog -s foo
39*0Sstevel@tonic-gate# or	uulog -ffoo
40*0Sstevel@tonic-gate# or	uulog -f foo
41*0Sstevel@tonic-gate#
42*0Sstevel@tonic-gate#	-x means check the execute file
43*0Sstevel@tonic-gate#	-nnn where 'nnn' is a number will do tail -nnn
44*0Sstevel@tonic-gate#
45*0Sstevel@tonic-gateLOGDIR=/var/uucp/.Log
46*0Sstevel@tonic-gatetype=uucico
47*0Sstevel@tonic-gatefflag=""
48*0Sstevel@tonic-gatesys=""
49*0Sstevel@tonic-gaten=""
50*0Sstevel@tonic-gate
51*0Sstevel@tonic-gatecd $LOGDIR
52*0Sstevel@tonic-gate
53*0Sstevel@tonic-gatewhile getopts :xf:s:0123456789 FLAG; do
54*0Sstevel@tonic-gate	case $FLAG in
55*0Sstevel@tonic-gate	x)	type=uuxqt
56*0Sstevel@tonic-gate		;;
57*0Sstevel@tonic-gate	f)	fflag=1
58*0Sstevel@tonic-gate		sys="$sys $OPTARG"
59*0Sstevel@tonic-gate		;;
60*0Sstevel@tonic-gate	s)	sys="$sys $OPTARG"
61*0Sstevel@tonic-gate		;;
62*0Sstevel@tonic-gate	:)	gettext "uulog: System name must follow -$OPTARG flag\n" 1>&2
63*0Sstevel@tonic-gate		exit 1
64*0Sstevel@tonic-gate		;;
65*0Sstevel@tonic-gate	[0-9])	n=$n$FLAG
66*0Sstevel@tonic-gate		;;
67*0Sstevel@tonic-gate	*)	gettext "Usage: uulog [-x] [-f system] | [[-number] [-s system...]]\n" 1>&2
68*0Sstevel@tonic-gate		exit 1
69*0Sstevel@tonic-gate		;;
70*0Sstevel@tonic-gate	esac
71*0Sstevel@tonic-gatedone
72*0Sstevel@tonic-gate
73*0Sstevel@tonic-gateshift `expr $OPTIND - 1`
74*0Sstevel@tonic-gate
75*0Sstevel@tonic-gatesys="$sys $*"
76*0Sstevel@tonic-gate
77*0Sstevel@tonic-gateset - $sys
78*0Sstevel@tonic-gateif [ x$fflag = x ]; then
79*0Sstevel@tonic-gate	if [ $# = 0 ]; then
80*0Sstevel@tonic-gate		set - `/usr/bin/ls $type`
81*0Sstevel@tonic-gate	fi
82*0Sstevel@tonic-gate	for i in $*
83*0Sstevel@tonic-gate	do
84*0Sstevel@tonic-gate		if [ -f $type/$i ]
85*0Sstevel@tonic-gate		then
86*0Sstevel@tonic-gate			if [ x$n = x ]; then
87*0Sstevel@tonic-gate				cat $type/$i
88*0Sstevel@tonic-gate			else
89*0Sstevel@tonic-gate				tail -$n $type/$i
90*0Sstevel@tonic-gate			fi
91*0Sstevel@tonic-gate		else
92*0Sstevel@tonic-gate			printf "`gettext 'uulog: No log file available for system %s'`\n" $i  1>&2
93*0Sstevel@tonic-gate			exit 1
94*0Sstevel@tonic-gate		fi
95*0Sstevel@tonic-gate	done
96*0Sstevel@tonic-gateelse
97*0Sstevel@tonic-gate	if [ $# != 1 ]; then
98*0Sstevel@tonic-gate		gettext "uulog: Only one system allowed with -f\n" 1>&2
99*0Sstevel@tonic-gate		exit 2
100*0Sstevel@tonic-gate	fi
101*0Sstevel@tonic-gate	if [ -f $type/$1 ]
102*0Sstevel@tonic-gate	then
103*0Sstevel@tonic-gate		exec tail -${n}f $type/$1
104*0Sstevel@tonic-gate	else
105*0Sstevel@tonic-gate		printf "`gettext 'uulog: No log file available for system %s'`\n" $1 1>&2
106*0Sstevel@tonic-gate		exit 1
107*0Sstevel@tonic-gate	fi
108*0Sstevel@tonic-gatefi
109