Listing 8
#!/bin/sh
###################################################################
#              Add Print Quota Script for Consultant              #
#                                                                 #
# --------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or   #
# modify it under the terms of the GNU General Public License     #
# as published by the Free Software Foundation; either version 2  #
# of the License, or (at your option) any later version.          #
#                                                                 #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of  #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   #
# GNU General Public License for more details.                    #
#                                                                 #
# You should have received a copy of the GNU General Public       #
# License along with this program; if not, write to the Free      #
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, #
# MA  02111-1307, USA.                                            #
###################################################################
quotalog=/PrnQT/log/quotalog
smquota=/PrnQT/log/97fall
tmp=/PrnQT/prnquota/usrinfo
tmp1=/tmp/qlog
consult=`set |grep LOGNAME|cut -d"=" -f2`
if [ ! -f $quotalog ]
then
  touch $quotalog
fi
tickno=$3
upname=`echo $tickno|nawk '{ print toupper($1) }'`
tickno=$upname
echo $tickno|grep DP
if [ $? -eq 0 ]
then
  dup="DP"
else
  dup="no"
fi
nodigit=`echo $tickno|wc -c`
tuser=$1
nismatch $tuser passwd.org_dir >>/dev/null
if [ $? -ne 0 ]
then
  echo "The user name is incorrect!! Please try again!!"
  exit 0
fi
if [ $dup != "DP" ]
then
  cat $quotalog|grep $tickno
  if [ $? -eq 0 ]
  then
    echo "Please try again. You have input a duplicated ticket number!!"
    exit 0
  else
    if [ $nodigit -ne 7 ]
    then
      echo "The account number is incorrect!! Please try again!!"
      exit 0
    fi
  fi
fi
echo "Please check all the input is correct!!"
echo "Correct? (y/n)"
read answer
if [ $answer != "Y" -a $answer != "y" ]
then
  echo "Please try it again!!"
else
  dat=`date '+%y%m%d%t%T'`
  usr=$tmp/$1
  tusr=$1
  addquota=100
  stid=$2
  tpusr=`cat $usr`
  ttpusr="$tpusr:$addquota"
  tmpfile=`echo $ttpusr|awk -F: '{ i=NF; $1=$1+$i; arr=$1; \
         for(i=2;i<=NF-1;i++) arr=arr ":" $i; print arr }'` 
  echo $tmpfile>$usr
  echo "$tusr  $stid  $tickno  $dat  $consult">>$quotalog
  echo "$tusr  $stid  $tickno  $dat  $consult">>$smquota
fi
