home *** CD-ROM | disk | FTP | other *** search
- From decwrl!labrea!rutgers!tut.cis.ohio-state.edu!cwjcc!hal!ncoast!allbery Sun Dec 11 17:11:23 PST 1988
- Article 746 of comp.sources.misc:
- Path: granite!decwrl!labrea!rutgers!tut.cis.ohio-state.edu!cwjcc!hal!ncoast!allbery
- From: rjs@a.cs.okstate.edu (Roland Stolfa)
- Newsgroups: comp.sources.misc
- Subject: v05i071: Trouble Reporting System
- Message-ID: <4227@okstate.UUCP>
- Date: 7 Dec 88 00:22:58 GMT
- Sender: allbery@ncoast.UUCP
- Reply-To: rjs@a.cs.okstate.edu (Roland Stolfa)
- Organization: Oklahoma State Univ., Stillwater
- Lines: 1334
- Approved: allbery@ncoast.UUCP
-
- Posting-number: Volume 5, Issue 71
- Submitted-by: "Roland Stolfa" <rjs@a.cs.okstate.edu>
- Archive-name: trouble
-
- echo x - README
- sed '1,$s/^X//' <<\!FUNKY!STUFF! > README
- XINTRODUCTION:
- X
- X This is the Trouble Report System (TRS) by
- X
- X Roland J. Stolfa
- X Department of Computing and Information Sciences
- X Oklahoma State University
- X
- X Internet: rjs@a.cs.okstate.edu
- X
- X
- XDISCLAIMER:
- X
- X All code is public domain. No guarentee, expressed nor implied,
- X covers this code. I will NOT be responsible for it's use or
- X misuse in your application. I just hope (Underline that in red)
- X that it may prove useful to you. If something doesn't compile,
- X I hope that the comments that surround the troble line will be
- X sufficient to fix the problem.
- X
- X
- XDESCRIPTION:
- X
- X This is a set of Bourne shell scrips and C programs intended
- X to maintain a database of trouble reports. The actions supported
- X in this package are open a trouble report (trouble), post a followup
- X on a trouble report (followup), remove a 'thread' of trouble reports
- X (rmthread), report all open trouble report ticket numbers (opentr),
- X and summarize a class of trouble reports (report).
- X
- X
- XINSTALLATION PROCEDURES:
- X
- X1. Make a directory and put this shar in it. Then say "sh <fn>".
- X
- X2. Edit the file "Localize" to point the "ROOT", "BIN" and
- X shell script escape sequences at the localally correct
- X values. Then type "sh Localize" to install these values
- X on all files in this directory. Then edit the Makefile
- X and change the -DSYS5 to either -DSYS5 or -DULTRIX.
- X
- X3. Say "make install". This makes the various directories &
- X sets the permissions to allow the next procedure to function.
- X
- X4. Say "make all".
- X
- X5. Done.
- X
- X
- XDIRECTORY STRUCTURE:
- X
- X Trs
- X |
- X +-------+------------+----------+---------------+-------+
- X | | | | | |
- X Entry <Soundex1> ... <SoundexN> tmp bin
- X | | | |
- X +---+-----+ +-------+-+ +----+----+ +-----+
- X | ... | | ... | | ... | | ... |
- X <Timestamp1> ... <Timestamp1> ..<Timestamp1> ... trs.seq <temps>
- X
- XEach TRS record is first built in a temporary. It is then linked into the
- X.../Trs/Entry/<Timestamp>" file. Then it is linked into a subdirectory
- Xfor each SOUNDEX encoded keyword given during data entry.
- X
- X
- XNOTES:
- X
- X1. If you need to move this datastructure, please use a program
- X that preserves the link relationships.
- X
- X2. If the average TRS record size is small and the default
- X block size on the storage device is large, you loose...
- X
- X3. This system typically uses a large number of links. This
- X implies that a large number of inodes will be used. This
- X can be a problem on smaller systems...
- X
- X4. Each user can override the default "ROOT" setting by having
- X an environment variable "TRSROOT" set to some directory
- X that has the same structure as the one above.
- X
- X
- XFILES:
- X
- X Localize
- X
- X This shell script patches all the files in this system to
- X work with the locally chosen directories.
- X
- X Makefile
- X
- X Used to create all the executables for each program.
- X
- X README
- X
- X This file.
- X
- X followup.sh
- X
- X This program is used to enter a follow up report onto
- X the end of a TRS thread. It walks the thread, from anywhere
- X on the thread, to then end and then doubly links the end
- X of the current thread to the new report.
- X
- X mkpath.c
- X
- X A utility program to generate directories along a given
- X path without complaining.
- X
- X opentr.sh
- X
- X This shell script lists the initial trouble report ticket
- X number for all active trouble reports.
- X
- X parse.awk
- X
- X This "awk(1)" program is used to parse the command line
- X arguments to "report.sh".
- X
- X print.c
- X
- X This simple program is used to print all the command line
- X arguments on a line by itself without a carriage return
- X on the end.
- X
- X report.sh
- X
- X This shell script attempts to extract data from the TRS
- X database given any combination of keys.
- X
- X reporter.awk
- X
- X This "awk(1)" program is used in one stage of the "report.sh"
- X program.
- X
- X rmthread.sh
- X
- X This shell script removes an entire linked list of trouble
- X reports, given a report anywhere in the list.
- X
- X soundex.c
- X
- X This C program implements a "SOUNDEX" algorithm and is used
- X in the TRS to encode keywords within the database to ease
- X searching.
- X
- X trouble.sh
- X
- X This shell script does the actual data entry for the TRS system.
- X It attempts to prompt for all the relavant data, generates
- X some stuff by default, and then builds all the linked files
- X that constitue the database.
- !FUNKY!STUFF!
- echo x - Localize
- sed '1,$s/^X//' <<\!FUNKY!STUFF! > Localize
- X#
- X# Localizing script for the (T)rouble (R)eport (S)ystem
- X#
- X
- Xfor i in Makefile *.sh
- Xdo
- X
- X #
- X # Attach the "ROOT" to some clean point like /usr/local/lib/trs
- X # as this will need to be a publically writable directory that
- X # will hold all trouble reports.
- X #
- X # Attach the "BIN" to some global point like /usr/lbin for all
- X # the executables
- X #
- Xed - $i <<'EOF'
- Xg;^ROOT;s;=.*$;=/u/rjs/lib/Trs;
- Xg;^BIN;s;=.*$;=/u/rjs/bin;
- Xw
- Xq
- XEOF
- X
- Xdone
- X
- Xfor i in *.sh
- Xdo
- X
- X #
- X # The ":" in the ed script below is the first line of all shell
- X # scripts for SYS5. For ULTRIX, it should be "#!/bin/sh".
- X #
- Xed - $i <<'EOF'
- X1 s;^.*$;:;
- Xw
- Xq
- XEOF
- X
- Xdone
- !FUNKY!STUFF!
- echo x - Makefile
- sed '1,$s/^X//' <<\!FUNKY!STUFF! > Makefile
- X#
- X# Package : TRS
- X# Module : (Makefile)
- X# Programmer : R. Stolfa
- X#
- X# Purpose : To maintain a Trouble Report System for an
- X# university environment
- X#
- X# Modification History:
- X# 04/11/88 Created
- X# 10/25/88 Updated for distribution outside of OSU
- X#
- XROOT=/u/rjs/lib/Trs
- XLIB=$(ROOT)/lib
- XBIN=/u/rjs/bin
- XCFLAGS= -O -DSYS5
- X
- XDuMb:
- X @echo Make what?
- X
- Xfollowup: $(BIN)/followup
- X$(BIN)/followup: followup.sh
- X cp followup.sh $(BIN)/followup
- X chmod 755 $(BIN)/followup
- X
- Xmkpath: $(LIB)/mkpath
- X$(LIB)/mkpath: mkpath.c
- X cc $(CFLAGS) mkpath.c -o $(LIB)/mkpath
- X chmod 755 $(LIB)/mkpath
- X
- Xopentr: $(BIN)/opentr
- X$(BIN)/opentr: opentr.sh
- X cp opentr.sh $(BIN)/opentr
- X chmod 755 $(BIN)/opentr
- X
- XParse.awk: $(LIB)/parse.awk
- X$(LIB)/parse.awk: parse.awk
- X cp parse.awk $(LIB)/parse.awk
- X chmod 644 $(LIB)/parse.awk
- X
- Xprint: $(LIB)/print
- X$(LIB)/print: print.c
- X cc print.c -o $(LIB)/print
- X chmod 755 $(LIB)/print
- X
- Xreport: Parse.awk Reporter.awk $(BIN)/report
- X$(BIN)/report: report.sh
- X cp report.sh $(BIN)/report
- X chmod 755 $(BIN)/report
- X
- XReporter.awk: $(LIB)/reporter.awk
- X$(LIB)/reporter.awk: reporter.awk
- X cp reporter.awk $(LIB)/reporter.awk
- X chmod 644 $(LIB)/reporter.awk
- X
- Xrmthread: $(BIN)/rmthread
- X$(BIN)/rmthread: rmthread.sh
- X cp rmthread.sh $(BIN)/rmthread
- X chmod 755 $(BIN)/rmthread
- X
- Xsoundex: $(LIB)/soundex
- X$(LIB)/soundex: soundex.c
- X cc soundex.c -o $(LIB)/soundex
- X chmod 755 $(LIB)/soundex
- X
- Xtrouble: $(BIN)/trouble
- X$(BIN)/trouble: trouble.sh
- X cp trouble.sh $(BIN)/trouble
- X chmod 755 $(BIN)/trouble
- X
- X#
- X# Housekeeping
- X#
- X
- Xall: followup opentr mkpath print report rmthread soundex trouble
- X @echo "Don't forget 'make install' to setup sequence file"
- X
- Xbackout: clean
- X rm -rf $(ROOT)
- X rm -if $(BIN)/followup $(BIN)/opentr $(BIN)/report $(BIN)/rmthread \
- X $(BIN)/trouble
- X
- Xclean:
- X rm -f *.o a.out core
- X
- Xinstall:
- X -mkdir $(ROOT) $(ROOT)/Entry $(ROOT)/tmp $(ROOT)/lib
- X chmod 777 $(ROOT) $(ROOT)/Entry $(ROOT)/tmp
- X chmod 755 $(ROOT)/lib
- X echo "0" > $(ROOT)/sequence
- X
- Xshar:
- X shar README Localize Makefile [a-z]* > Trs.shar
- X
- X#
- X# Dependancies
- X#
- Xmkpath.o print.o soundex.o : /usr/include/stdio.h
- !FUNKY!STUFF!
- echo x - followup.1
- sed '1,$s/^X//' <<\!FUNKY!STUFF! > followup.1
- X.TH FOLLOWUP L
- X.SH NAME
- Xfollowup - post a followup trouble report
- X.SH SYNOPSIS
- X.B followup [ ticket number ]
- X.br
- X.SH DESCRIPTION
- X.I followup
- Xis intended to be the method of posting a new report in a "thread" of
- Xreports assoicated with a reported problem in hardware/software.
- X.PP
- XIf
- X.I followup
- Xis invoked without a ticket number, it prompts for one. Then an entire
- Xnew trouble report is attached to a thread of reports assoicated together.
- XThis list of reports is doubly linked in the trouble report file and then
- Xlinked (using "ln(1)") to all soundex encoded subdirectories relating
- Xto the keywords specified.
- X.PP
- XAll of the files and directories contained in the system are all plain
- Xtext files, with an easy format that can be used to your advantage.
- X.sp 1
- X.SH "INTERNALS"
- X.I followup
- Xuses a tree structured file data-base to store all trouble reports. Each
- Xreport occupies one file in the "../Trs/Entry" directory with the name
- Xbeing equal to that of the date (in YYMMDD format) and a sequence number
- Xappended (i.e. 881025.1). This file is then linked (using "ln(1)") to
- Xa subdirectory for each keyword specified in the
- X.I followup
- Xkeyword prompt. Each keyword is encoded via the
- X.I soundex
- Xalgorythm to be the "link" directory. This allows fast searches of
- Xrecurring problems (see "report(L)").
- X.SH "FILES"
- X"/usr/local/lib/trs/...." - Root directory for help
- X.br
- X"/usr/local/lib/trs/entry/..." - Directory where ALL trouble reports reside
- X.br
- X"/usr/local/lib/trs/sequence" - Sequence file
- X.PP
- X.SH DIAGNOSTICS
- XThere are no real diagnostics.
- X.SH AUTHOR
- XRoland J. Stolfa
- X.br
- XDepartment of Computing and Information Sciences
- X.br
- XOklahoma State University
- X.br
- Xrjs@a.cs.okstate.edu
- !FUNKY!STUFF!
- echo x - followup.sh
- sed '1,$s/^X//' <<\!FUNKY!STUFF! > followup.sh
- X:
- X#
- X# Package : TRS
- X# Module : followup.sh
- X# Programmer : R. Stolfa
- X#
- X# Purpose : To 'needle & thread' TRS records together.
- X#
- X# Modification History:
- X# 04/12/88 Created
- X# 10/25/88 Added user configurable "ROOT" to allow more than
- X# one TRS to exist on a particular system.
- X#
- X
- X#
- X# Some variables
- X#
- Xumask 000
- Xif [ "$TRSROOT" != "" ]
- Xthen
- X ROOT=$TRSROOT
- Xelse
- XROOT=/u/rjs/lib/Trs
- Xfi
- XBIN=/u/rjs/bin
- XENTRY=$ROOT/Entry
- XLIB=$ROOT/lib
- Xtrap "rm -f $ROOT/tmp/* ; exit 1" 1 2 15
- X
- X#
- X# Ok. Get the 'trouble ticket' number.
- X#
- Xnum="$*"
- Xif test ! -s $ENTRY/$num
- Xthen
- X echo "Invalid trouble ticket number. Try again."
- X num=""
- Xfi
- Xwhile [ "$num" = "" ]
- Xdo
- X $LIB/print "Enter trouble ticket number? "
- X read num
- X
- X if test ! -s $ENTRY/$num
- X then
- X echo "Invalid trouble ticket number. Try again."
- X num=""
- X fi
- Xdone
- X
- X#
- X# Follow it's threads until you reach the last one.
- X#
- Xthread="+"
- Xwhile [ "$thread" != "" ]
- Xdo
- X thread="`grep '^thread=' $ENTRY/$num | awk -F= '{print $2}'`"
- X if [ "$thread" != "" ]
- X then
- X num="$thread"
- X fi
- Xdone
- X
- X#
- X# Display last entry.
- X#
- Xecho "Last entry as follows:"
- Xecho ""
- Xecho "ticket=$num"
- Xecho "reporter=`ls -l $ENTRY/$num | awk '{print $3}'`"
- Xmore $ENTRY/$num
- Xecho ""
- Xyesno=""
- Xwhile [ "$yesno" = "" ]
- Xdo
- X $LIB/print "Is this the correct one? (Y/N) "
- X read yesno
- Xdone
- X
- X#
- X# If incorrect, try again.
- X#
- Xif [ "$yesno" = "N" -o "$yesno" = "n" ]
- Xthen
- X exec $BIN/followup
- Xfi
- X
- X#
- X# Ok. Generate a new trouble report and then fix the threading.
- X# Do this by 'including' the trouble ticket generator.
- X#
- Xnumber=$num
- X. $BIN/trouble
- Xecho "thread=$NTN" >> $ENTRY/$number
- Xecho "needle=$num" >> $ENTRY/$NTN
- !FUNKY!STUFF!
- echo x - mkpath.c
- sed '1,$s/^X//' <<\!FUNKY!STUFF! > mkpath.c
- X/*
- X * Package : TRS
- X * Module : mkpath.c
- X * Programmer : R. Stolfa
- X *
- X * Purpose : To create all the subdirectories that are needed
- X * for a file specified on the command line.
- X *
- X * Usage:
- X * % mkpath foo/bar/cat/dog
- X * Will make the directories foo, foo/bar, and foo/bar/cat
- X * if they don't already exist.
- X *
- X * Modification History:
- X * 02/15/88 Created
- X */
- X
- X#include <stdio.h>
- X
- Xmain (argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X int i;
- X
- X for (i = 1; i < argc; i ++)
- X mkpath (argv[i]);
- X}
- X
- Xmkpath (name)
- Xchar name[];
- X{
- X
- X char buff[512];
- X int i,
- X dumb;
- X#ifdef SYS5
- X char cmd[512];
- X#endif
- X
- X for (i = 0; i < strlen(name); i ++) {
- X buff[i] = '\0';
- X if (name[i] == '/') {
- X#ifdef ULTRIX
- X dumb = mkdir (buff, 0755);
- X#endif
- X
- X#ifdef SYS5
- X sprintf (cmd, "mkdir %s > /dev/null 2>&1", buff);
- X system (cmd);
- X#endif
- X }
- X buff[i] = name[i];
- X }
- X}
- !FUNKY!STUFF!
- echo x - opentr.1
- sed '1,$s/^X//' <<\!FUNKY!STUFF! > opentr.1
- X.TH OPENTR L
- X.SH NAME
- Xopentr - report all open trouble reports
- X.SH SYNOPSIS
- X.B opentr
- X.br
- X.SH DESCRIPTION
- X.I opentr
- Xis intended to be used to find all open trouble reports to give
- Xthe trouble manager something to do in their spare time :-).
- X.SH AUTHOR
- XRoland J. Stolfa
- X.br
- XDepartment of Computing and Information Sciences
- X.br
- XOklahoma State University
- X.br
- Xrjs@a.cs.okstate.edu
- !FUNKY!STUFF!
- echo x - opentr.sh
- sed '1,$s/^X//' <<\!FUNKY!STUFF! > opentr.sh
- X:
- X#
- X# Package : TRS
- X# Module : opentr.sh
- X# Programmer : R. Stolfa
- X#
- X# Purpose : To list all open trouble report ticket numbers
- X# in the TRS database.
- X#
- X# Modification History:
- X# 04/15/88 Created
- X# 10/25/88 Added a user configurable "ROOT" to allow more than
- X# one TRS on a system.
- X#
- X
- X#
- X# Some variables
- X#
- Xumask 000
- Xif [ "$TRSROOT" != "" ]
- Xthen
- X ROOT=$TRSROOT
- Xelse
- XROOT=/u/rjs/lib/Trs
- Xfi
- XENTRY=$ROOT/Entry
- XLIB=$ROOT/lib
- Xif [ `ls $ENTRY | wc -l` -gt 0 ]
- Xthen
- X for i in $ENTRY/*
- X do
- X if [ `grep "^needle=" $i | wc -l` -eq 0 ]
- X then
- X echo `basename $i`
- X fi
- X done
- Xfi
- !FUNKY!STUFF!
- echo x - parse.awk
- sed '1,$s/^X//' <<\!FUNKY!STUFF! > parse.awk
- X#
- X# Package : TRS
- X# Module : parse.awk
- X# Programmer : R. Stolfa
- X#
- X# Purpose : To parse the command line arguments to "report.sh".
- X#
- X# Modification History:
- X# 04/12/88 Created
- X#
- X
- XBEGIN {
- X FS = "=";
- X}
- X
- X{
- X if (NF == 2) {
- X char = substr ($1, 0, 1);
- X if ((char == "t") || (char == "T"))
- X printf "T\n";
- X else if ((char == "k") || (char == "K"))
- X printf "K\n";
- X else if ((char == "d") || (char == "D"))
- X printf "D\n";
- X else if ((char == "r") || (char == "R"))
- X printf "R\n";
- X else if ((char == "e") || (char == "E"))
- X printf "E\n";
- X }
- X}
- !FUNKY!STUFF!
- echo x - print.c
- sed '1,$s/^X//' <<\!FUNKY!STUFF! > print.c
- X/*
- X * Package : TRS
- X * Module : print.c
- X * Programmer : R. Stolfa
- X *
- X * Purpose : To provide a portable way of printing a string
- X * of text on stdout without having a newline at the
- X * end.
- X *
- X * Modification History:
- X * 04/01/88 Created
- X */
- X
- X#include <stdio.h>
- X
- Xmain (argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X int i;
- X
- X if (argc > 1) {
- X for (i = 1; i < argc - 1 ; i ++)
- X printf ("%s ", argv[i]);
- X
- X printf ("%s", argv[argc-1]);
- X }
- X}
- !FUNKY!STUFF!
- echo x - report.1
- sed '1,$s/^X//' <<\!FUNKY!STUFF! > report.1
- X.TH REPORT L
- X.SH NAME
- Xreport - extract all requested trouble reports by selection criteria
- X.SH SYNOPSIS
- X.B report [ t=<thread> ] [ k=<keyword> ] [ d=<date> ] [ r=<reporter> ] [ e=<equipment> ]
- X.br
- X.SH DESCRIPTION
- X.I report
- Xis intended to extract the utmost information from the (T)rouble (R)eport
- X(S)ystem. With this shell script, you can extract an entire thread
- Xusing the
- X.B [ t=<thread id> ]
- Xoption, or you may select all reports with a particular keyword
- Xusing the
- X.B [ k=<keyword> ]
- Xoption. In addition, you may select all reports on a particular day
- Xusing the
- X.B [ d=<date> ]
- Xoption. If that isn't enough, you can select a particular reporter (read that
- Xas UN*X user login id) by using the
- X.B [ r=<reporter> ]
- Xoption. Lastly, you can use the
- X.B [ e=<equipment id string> ]
- Xoption to extract all info about a particular peice of equipment and or a class
- Xof equipment, depending on what you use for the
- X.B <equipment id string>.
- X.PP
- XIn addition, you can use the different options of
- X.I report
- Xadditvely. Several examples follow.
- X.PP
- Xreport t=881025.1 e="terminal"
- X.br
- Xextracts all trouble report entries in the thread assoicated with the head
- Xof the thread pointed to by 881025.1 that deal with the "terminal" class
- Xof devices.
- X.PP
- Xreport d=881025 r=joe e="terminal"
- X.br
- Xextracts all trouble reports on 10/25/88 by user "joe" involving a
- X"terminal".
- X.PP
- Xreport k=broken e="terminal"
- X.br
- Xextracts all trouble reports about "broken" "terminal"s.
- X.PP
- XIn short, you get the idea.
- X.sp 1
- X.SH "INTERNALS"
- X.I report
- Xuses a single pass over the arguments above
- X.B IN THE LISTED ORDER
- Xto refine the eventual list of trouble report tickets to be printed
- Xas the "report". Note that any missordering of the arguments will be
- Xhandled by re-ordering them as listed above BEFORE selection occurs.
- X.sp 1
- X.SH DIAGNOSTICS
- XThere are no real diagnostics. You are expected to be able to fathom
- Xthe deep-dark recesses of shell programming & have a good working knowledge
- Xof links in order to do ANY debugging of this system.
- X.sp 1
- X.SH AUTHOR
- XRoland J. Stolfa
- X.br
- XDepartment of Computing and Information Sciences
- X.br
- XOklahoma State University
- X.br
- Xrjs@a.cs.okstate.edu
- !FUNKY!STUFF!
- echo x - report.sh
- sed '1,$s/^X//' <<\!FUNKY!STUFF! > report.sh
- X:
- X#
- X# Package : TRS
- X# Module : report.sh
- X# Programmer : R. Stolfa
- X#
- X# Purpose : To scan the TRS database and extract "reasonable"
- X# information. This information will be presented
- X# on the screen in a format suitable for printing
- X#
- X# Command line syntax:
- X# report <flags>
- X# where <flags> are some set of the following
- X#
- X# t=<thread id>
- X# k=<keyword to search on>
- X# d=<date in YYMMDD format>
- X# r=<reporter (userid)>
- X# e=<equipment id string (inventory number?)>
- X#
- X# Modification History:
- X# 04/12/88 Created
- X# 10/25/88 Added a user configurable "ROOT" to allow more than
- X# one TRS on a system
- X#
- X
- X#
- X# Some variables
- X#
- Xumask 000
- Xif [ "$TRSROOT" != "" ]
- Xthen
- X ROOT=$TRSROOT
- Xelse
- XROOT=/u/rjs/lib/Trs
- Xfi
- XENTRY=$ROOT/Entry
- XLIB=$ROOT/lib
- XTEMP=$ROOT/tmp/trs.$$
- XTEMP2=$ROOT/tmp/trs2.$$
- XTEMP3=$ROOT/tmp/trs3.$$
- Xtrap "rm -f $ROOT/tmp/* ; exit 1" 1 2 15
- X
- Xthread=""
- Xkey="Entry"
- Xdate="*"
- Xreporter=""
- Xequip=""
- X
- X#
- X# Parse the command line with "parse.awk"
- X#
- Xfor i in $*
- Xdo
- X case `echo $i | awk -f $LIB/parse.awk` in
- X T)
- X thread="`echo $i | awk -F= '{print $2}'`"
- X continue;;
- X K)
- X item=`echo $i | awk -F= '{print $2}'`
- X key=`$LIB/soundex $item`
- X continue;;
- X D)
- X date="`echo $i | awk -F= '{print $2}'`"
- X continue;;
- X R)
- X reporter="`echo $i | awk -F= '{print $2}'`"
- X continue;;
- X E)
- X equip="`echo $i | awk -F= '{print $2}'`"
- X continue;;
- X esac
- Xdone
- X
- X#
- X# Separate out a thread (if required).
- X#
- Xif [ "$thread" != "" ]
- Xthen
- X #
- X # Ok. Let's generate a thread list.
- X #
- X if test ! -s $ENTRY/$thread
- X then
- X echo "Invalid thread id. Try again."
- X exit
- X fi
- X rm -f $TEMP
- X #
- X # Find head of thread
- X #
- X needle=$thread
- X while [ "$needle" != "" ]
- X do
- X thread=$needle
- X needle="`grep '^needle=' $ENTRY/$needle | awk -F= '{print $2}'`"
- X done
- X #
- X # List the members of the thread
- X #
- X while [ "$thread" != "" ]
- X do
- X echo "$ENTRY/$thread" >> $TEMP
- X thread="`grep '^thread=' $ENTRY/$thread | awk -F= '{print $2}'`"
- X done
- Xelse
- X #
- X # Get all files
- X #
- X ls $ROOT/$key/$date* > $TEMP2 2>/dev/null
- X sort -u < $TEMP2 > $TEMP
- X date="*"
- X key=""
- Xfi
- X
- X#
- X# Now lets get the key field taken care of.
- X#
- Xif [ "$key" != "" ]
- Xthen
- X for i in `cat $TEMP`
- X do
- X ls $ROOT/$key/`basename $i` 2>/dev/null
- X done > $TEMP2
- X mv $TEMP2 $TEMP
- Xfi
- X
- X#
- X# Ok. Now let's generate the subset of the list that has occured on
- X# the date in question.
- X#
- Xif [ "$date" != "*" ]
- Xthen
- X grep "$date" < $TEMP > $TEMP2
- X mv $TEMP2 $TEMP
- Xfi
- X
- X#
- X# Do the awking for a particular reporter (if necessary).
- X#
- Xif [ "$reporter" != "" ]
- Xthen
- X echo "$reporter" > $TEMP2
- X ls -l `cat $TEMP` >> $TEMP2
- X awk -f $LIB/reporter.awk < $TEMP2 > $TEMP
- X rm $TEMP2
- Xfi
- X
- X#
- X# Do the greping for a particular piece of equipment (if necessary).
- X#
- Xif [ "$equip" != "" ]
- Xthen
- X grep -l "^equipment=$equip" `cat $TEMP` > $TEMP
- Xfi
- X
- X#
- X# Ok. More the junk to the screen...
- X#
- Xfor i in `cat $TEMP`
- Xdo
- X echo "ticket=`basename $i`"
- X echo "reporter=`ls -l $i | awk '{print $3}'`"
- X cat $i
- X echo ""
- Xdone | more
- X
- X#
- X# Now clean up and exit.
- X#
- Xrm -f $TEMP $TEMP2 $TEMP3
- !FUNKY!STUFF!
- echo x - reporter.awk
- sed '1,$s/^X//' <<\!FUNKY!STUFF! > reporter.awk
- X#
- X# Package : TRS
- X# Module : reporter.awk
- X# Programmer : R. Stolfa
- X#
- X# Purpose : This program returns only those lines with the
- X# correct user field as the reporter.
- X#
- X# Modification History:
- X# 04/12/88 Created
- X#
- X
- X{
- X if (NR == 1)
- X reporter = $1;
- X else if (NF > 1) {
- X if (substr($3, 0, length(reporter)) == reporter)
- X printf "%s\n", $NF;
- X }
- X}
- !FUNKY!STUFF!
- echo x - rmthread.1
- sed '1,$s/^X//' <<\!FUNKY!STUFF! > rmthread.1
- X.TH RMTHREAD L
- X.SH NAME
- Xrmthread - remove a trouble report system thread from anywhere on the thread
- X.SH SYNOPSIS
- X.B rmthread [threadid]
- X.br
- X.SH DESCRIPTION
- X.I rmthread
- Xis to be used when an entire thread of trouble reports have been delt with
- Xand the ammased information is no longer of any use. This program finds
- Xthe head of the list of trouble reports (on the thread given) and then builds
- Xa list of thread files to remove. It then displays the entire thread and
- Xasks you if you really want to remove it. If so, it then gets rid of all
- Xoccurances of the associated thread from the trouble report system.
- X.sp 1
- X.SH "INTERNALS"
- X.I rmthread
- Xuses an text line in the thread file to provide both a forward link to the
- Xnext trouble report and another text line to provide the backward link to
- Xthe previous trouble report. This is why it is so slow at times.
- X.sp 1
- X.SH AUTHOR
- XRoland J. Stolfa
- X.br
- XDepartment of Computing and Information Sciences
- X.br
- XOklahoma State University
- X.br
- Xrjs@a.cs.okstate.edu
- !FUNKY!STUFF!
- echo x - rmthread.sh
- sed '1,$s/^X//' <<\!FUNKY!STUFF! > rmthread.sh
- X:
- X#
- X# Package : TRS
- X# Module : rmthread.sh
- X# Programmer : R. Stolfa
- X#
- X# Purpose : To delete a thread of trouble reports in the TRS
- X# database system.
- X#
- X# Modification History:
- X# 04/12/88 Created
- X# 10/25/88 Added a user configurable "ROOT" to allow more than
- X# one TRS on a system
- X#
- X
- X#
- X# Some variables
- X#
- Xumask 000
- Xif [ "$TRSROOT" != "" ]
- Xthen
- X ROOT=$TRSROOT
- Xelse
- XROOT=/u/rjs/lib/Trs
- Xfi
- XENTRY=$ROOT/Entry
- XLIB=$ROOT/lib
- Xtrap "rm -f $ROOT/tmp/* ; exit 1" 1 2 15
- X
- X#
- X# Get the tread to delete.
- X#
- Xthread="$*"
- Xwhile [ "$thread" = "" ]
- Xdo
- X $LIB/print "Enter thread to delete? "
- X read thread
- X
- X if test ! -s $ENTRY/$thread
- X then
- X echo "Invalid thread. Try again"
- X thread=""
- X fi
- Xdone
- X
- X#
- X# Search backwards (if possible) for head of thread.
- X#
- Xneedle="+"
- Xwhile [ "$needle" != "" ]
- Xdo
- X needle="`grep '^needle=' $ENTRY/$thread | awk -F= '{print $2}'`"
- X if [ "$needle" != "" ]
- X then
- X thread="$needle"
- X fi
- Xdone
- X
- X#
- X# ASSERT:
- X# At this point, thread is the original trouble report ticket
- X# number. Now let's keep that number safe and display the thread
- X# to assure that it is the one that needs to be removed.
- X#
- X
- Xptr="$thread"
- Xecho "The following is the listing of this thread."
- Xecho ""
- Xwhile [ "$ptr" != "" ]
- Xdo
- X echo "ticket=$ptr"
- X echo "reporter=`ls -l $ENTRY/$ptr | awk '{print $3}'`"
- X cat $ENTRY/$ptr
- X echo ""
- X ptr="`grep '^thread=' $ENTRY/$ptr | awk -F= '{print $2}'`"
- Xdone | more
- X
- X#
- X# Prompt for removal.
- X#
- Xyesno=""
- Xwhile [ "$yesno" = "" ]
- Xdo
- X $LIB/print "Is this the thread you want to delete? (Y/N) "
- X read yesno
- Xdone
- X
- Xif [ "$yesno" = "n" -o "$yesno" = "N" ]
- Xthen
- X exit
- Xfi
- X
- X#
- X# Ok. We have permission. Just remove the whole stupid thing...
- X#
- Xptr="$thread"
- Xwhile [ "$ptr" != "" ]
- Xdo
- X thread="`grep '^thread=' $ENTRY/$ptr | awk -F= '{print $2}'`"
- X rm -f $ROOT/*/$ptr
- X ptr="$thread"
- Xdone
- !FUNKY!STUFF!
- echo x - soundex.c
- sed '1,$s/^X//' <<\!FUNKY!STUFF! > soundex.c
- X/*
- X * Package : TRS
- X * Program : soundex.c
- X * Programmer : Roland Stolfa
- X *
- X * Function : This program implements the SOUNDEX procedure as
- X * outlined on page 655 of "Database Design" by
- X * Gio Wiederhold. This procedure was originally
- X * introduced by Odell & Russel (1918) and was
- X * described by McEwen (1974).
- X *
- X * Usage : soundex <string1> <string2> ... <stringN>
- X */
- X
- X#include <stdio.h>
- X
- X#define BS 200
- X
- Xmain (argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X char sound[BS];
- X int i;
- X
- X if (argc == 1) {
- X fprintf (stderr,
- X "Usage: soundex <string1> <string2> ... <stringN>\n");
- X exit (-1);
- X }
- X
- X for (i = 1; i < argc; i ++) {
- X soundex (argv[i], sound);
- X printf ("%s\n", sound);
- X }
- X}
- X
- Xsoundex (word, sound)
- Xchar word[], /* String to convert to SOUNDEX */
- X sound[]; /* Output SOUNDEX */
- X{
- X int outpos, /* Current output position in SOUNDEX */
- X j; /* Index into word */
- X
- X /* Initialize return word */
- X outpos = 0;
- X sound[outpos] = '\0';
- X
- X /* If the word is null, then the output should be null */
- X if (strlen(word) == 0)
- X return;
- X
- X /* Copy first character of word to SOUNDEX */
- X sound[outpos] = toupper (word[0]);
- X
- X for (j = 1; j < strlen (word); j ++) {
- X
- X /* Convert each character to uppercase */
- X word[j] = toupper(word[j]);
- X
- X switch (word[j]) {
- X
- X /* Replace Labials with "1" */
- X case 'B':
- X case 'F':
- X case 'P':
- X case 'V':
- X if (sound[outpos] != '1') {
- X outpos ++;
- X sound[outpos] = '1';
- X }
- X break;
- X
- X /* Replace Gutterals & sibilants with "2" */
- X case 'C':
- X case 'G':
- X case 'J':
- X case 'K':
- X case 'Q':
- X case 'S':
- X case 'X':
- X case 'Z':
- X if (sound[outpos] != '2') {
- X outpos ++;
- X sound[outpos] = '2';
- X }
- X break;
- X
- X /* Replace Dentals with "3" */
- X case 'D':
- X case 'T':
- X if (sound[outpos] != '3') {
- X outpos ++;
- X sound[outpos] = '3';
- X }
- X break;
- X
- X /* Replace Longliquids with "4" */
- X case 'L':
- X if (sound[outpos] != '4') {
- X outpos ++;
- X sound[outpos] = '4';
- X }
- X break;
- X
- X /* Replace Nasals with "5" */
- X case 'M':
- X case 'N':
- X if (sound[outpos] != '5') {
- X outpos ++;
- X sound[outpos] = '5';
- X }
- X break;
- X
- X /* Replace Shortliquids with "6" */
- X case 'R':
- X if (sound[outpos] != '6') {
- X outpos ++;
- X sound[outpos] = '6';
- X }
- X break;
- X }
- X }
- X
- X /* Terminate the soundex string */
- X outpos ++;
- X sound[outpos] = '\0';
- X
- X /* Forcably trunicate soundex to 4 characters */
- X sound[4] = '\0';
- X}
- X
- !FUNKY!STUFF!
- echo x - trouble.1
- sed '1,$s/^X//' <<\!FUNKY!STUFF! > trouble.1
- X.TH TROUBLE L
- X.SH NAME
- Xtrouble - enter an initial trouble report
- X.SH SYNOPSIS
- X.B trouble
- X.br
- X.SH DESCRIPTION
- X.I trouble
- Xenters the inital trouble report in the trouble report system. It is
- Xused also by
- X.I followup
- Xto enter all followup trouble reports in the current thread.
- X.PP
- XThis program is self prompting and fairly self explanitory.
- X.sp 1
- X.SH AUTHOR
- XRoland J. Stolfa
- X.br
- XDepartment of Computing and Information Sciences
- X.br
- XOklahoma State University
- X.br
- Xrjs@a.cs.okstate.edu
- !FUNKY!STUFF!
- echo x - trouble.sh
- sed '1,$s/^X//' <<\!FUNKY!STUFF! > trouble.sh
- X:
- X#
- X# Package : TRS
- X# Module : trouble.sh
- X# Programmer : R. Stolfa
- X#
- X# Purpose : To enter trouble reports into the TRS database system.
- X#
- X# Modification History:
- X# 04/11/88 Created
- X# 04/12/88 Added hooks for recording the new trouble number in the
- X# environment variable NTN for use in "followup"
- X# 10/25/88 Added user configurable "ROOT" to allow more than
- X# one TRS on a system
- X#
- X
- X#
- X# Some variables
- X#
- Xumask 000
- Xif [ "$TRSROOT" != "" ]
- Xthen
- X ROOT=$TRSROOT
- Xelse
- XROOT=/u/rjs/lib/Trs
- Xfi
- XENTRY=$ROOT/Entry
- XLIB=$ROOT/lib
- XSEQ=$ROOT/sequence
- XTEMP=$ROOT/tmp/trs.$$
- Xtrap "rm -f $ROOT/tmp/* ; exit 1" 1 2 15
- X
- Xrm -f $TEMP
- X
- X#
- X# Prompt for what piece of equipment is down.
- X#
- Xequipment=""
- Xwhile [ "$equipment" = "" ]
- Xdo
- X $LIB/print "Enter equipment ID string? "
- X read equipment
- Xdone
- Xecho "equipment=$equipment" >> $TEMP
- X
- X#
- X# Get the keywords to link the file in "Entry" to under each
- X# of their respective "SOUNDEX" equivalents.
- X#
- Xecho "Enter the keywords that are to be associated with this"
- Xecho "report one per line, ending with a blank line."
- X$LIB/print "keywords=" >> $TEMP
- Xkeywords=""
- Xdummy="+"
- Xwhile [ "$dummy" != "" ]
- Xdo
- X read dummy
- X if [ "$dummy" != "" ]
- X then
- X $LIB/print "$dummy " >> $TEMP
- X keywords="$keywords`$LIB/soundex $dummy` "
- X fi
- Xdone
- Xecho "" >> $TEMP
- X
- X#
- X# Enter the report.
- X#
- Xecho "Enter report, ending with a blank line"
- Xdummy="+"
- Xwhile [ "$dummy" != "" ]
- Xdo
- X read dummy
- X if [ "$dummy" != "" ]
- X then
- X echo "desc=$dummy" >> $TEMP
- X fi
- Xdone
- X
- X#
- X# Attempt to link in to "Entry" directory. This could be an area
- X# of contension (for the sequence file). The following sheme was
- X# choosen to give some reasonable operation.
- X#
- Xcond=1
- Xwhile test $cond -ne 0
- Xdo
- X entry="`date '+%y%m%d'`.`cat $SEQ`"
- X seq=`cat $SEQ`
- X expr $seq + 1 > $SEQ
- X ln $TEMP $ENTRY/$entry
- X cond=$?
- X if test $cond -ne 0
- X then
- X echo "Collision. Attempting fix..."
- X fi
- Xdone
- Xrm $TEMP
- X
- X#
- X# Report the "trouble ticket" number for future 'threading'.
- X#
- Xecho " "
- Xecho "Your trouble ticket number is $entry"
- Xecho "save this number for future reference."
- X
- X#
- X# Record the new trouble number in the environment variable NTN.
- X#
- XNTN=$entry
- X
- X#
- X# Now link the "Entry" directory trouble report to a file with
- X# the same timestamp.sequence filename in a directory for each of
- X# the "SOUNDEX" keywords. This is in an attempt to make the
- X# system easier to search.
- X#
- Xfor i in $keywords
- Xdo
- X $LIB/mkpath $ROOT/$i/$entry
- X ln $ENTRY/$entry $ROOT/$i/$entry
- Xdone
- X
- X#
- X# Ok. Let's be clean...
- X#
- Xrm -f $TEMP
- !FUNKY!STUFF!
-
-
-