#! /bin/sh
#**********************************************************************#
#*                                                                    *#
#* Copyright (c) 2001 by Sun Microsystems, Inc.                       *#
#* All rights reserved.                                               *#
#*                                                                    *#
#**********************************************************************#

#
#
# sample SH script for writing files to tape and writing messages
# to log files.
# This C shell script does nothing. It is up to the site to make
# the necessary changes to process the accounting journal files.
# The shell script does contain examples on how to perform the following
# functions:
#		* write messages to the unikixmain.log, unikixmain.err,
#		  unikixmain.dbg logs.
#		* write a message to the system console
#		* write the accounting file to tape
#
# One argument is passed to the shell script, the accounting file name.


# Calculate size of file
#SIZE=`du -s $1`

# set Date
#DATE=`date`

# How to write a message to the console
#    echo "Entering kixjournal for accounting file $1, Size: $SIZE, Date: $DATE." >       /dev/console

# How to write a message to the file: unikixmain.log
#    kixlog "Entering kixjournal for journal $1, Size: $SIZE, Date: $DATE"

# How to write a message to the file: unikixmain.err
#    kixlog -e "Entering kixjournal for journal $1, Size: $SIZE, Date: $DATE"

# How to write a message to the file: unikixmain.dbg
#    kixlog -d "Entering kixjournal for journal $1, Size: $SIZE, Date: $DATE"


#    DIR=`pwd`
#
# How to write accounting journal to tape and if necessary, wait for
# tape drive if it is busy.
# The following shows 2 methods to write to tape, cpio and tar:(assuming
# the accounting file is under $DIR)
#
# Method 1: cpio
# find $DIR -print | cpio -ovB > /dev/8mm
# Method 2: tar
# tar cvf /dev/8mm $DIR
#
# Example of writing accounting file $1 to tape and waiting for tape
# drive if it's busy.
#
#    tar cvf /dev/8mm $DIR
#    last_status=$status
#    while ($last_status)
#    	echo "device is not available, waiting..." 
#    	kixlog "device is not available, waiting..."&
#    	sleep 15
#    	tar cvf /dev/8mm $DIR
#    	last_status=$status
#    end

#DATE=`date`

# The "&" at the end of kixlog command is to return immediately
# to caller without waiting. This will prevent possible hangup.
#
#kixlog "Exiting kixjournal for file $1, Date: $DATE"&

#exit 
