#!/bin/ksh
# @(#) docindex - v01.00.04 - Wed Oct 10 10:10:10 EST 2001
          version=v01.00.04
# Modified by Jerry Rains - 10/31/00, 02/18/01 & 01/02/02.

PROG=${0##*/}
[ ~root = "~root" ] && exec /bin/ksh $0 $@  # assure the KornShell executes it

# Bob Stockler suggested this method of documenting indexes.  He was gracious
#    enough to allow me to make major modifications to his docindex program.
#    He does not support this version.
# 1) Added display of location of Documentation (index.doc) and saved previous
#    index.doc if found.
# 2) Modified all exit statements to include "Press Enter to continue so
#    that message could be seen prior to returning to filePro menu.
# 3) Nancy Palmquist modified the "rebuild all indexes" portion of the script to
#    generate a 'script' that would then be run to actually rebuild the indexes.
#    I modified her script to work from the Installation Utilities menu.
# 4) 1/22/01 - In modifying for Linux found that set -A doesn't work. Modified
#    to put $PFDSK into a file then read the data back into FS[i].
#    1/2/02 - Took out ability to do more than one filePro filesystem (FS[i]).
# 5) 2/17/01 - The ) in the following line was causing dxmaint to fail on 
#    indexes built on associated files.  Removed the ) from the associated field
#    number prior to writing to rbldindex.
# 6) Different awks handle \ in ascii statements differently.  OSR5 awk 
#    required \\ other awks don't.  Added test that sets \\ or \ as appropriate.
#    This was causing lower case letters in comments to be incremented by 1.
# 7) Added routine to save old rbldindex and index.doc in $PFDATA$PFDIR.
# 8) 2/18/01 - hd command is not recognized by Linux.  Changed to od command.
# 9) Wrote shell script to replace SCO builtin function 'whence'.
#10) 1/2/02 - Reversed position of edit and field_name.  If field_name is long
#    edit was being pushed off of index.doc.

#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#  README  #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#

# assign default destination for human-readable index documentation:
REPORT1=$PFDATA$PFDIR/report1
# report1 is in a format suitable for documentation

# assign default destination for script-readable index documentation:
REPORT2=$PFDATA$PFDIR/report2
# report2 is in a format suitable for reading by a script 
# to hand information to 'dxmaint' to rebuild an index

# See the bottom of this file for examples of the output of the two reports.

Usage="\
        Document filePro indexes ($version):

        Syntax:  $PROG [ args ]

        Arguments may be one or more of the following:

          -f filename    - filePro file name or quoted pattern
          -m qualifier   - qualifier name, quoted pattern or null (\"\")
          -i index       - index letter, number or quoted pattern
          -d             - divert report(s) to the standard output
          -q             - quiet (no progress display on the terminal)
          -s             - script-readable report suppressed
          -a             - combines the effects of -q, -d and -s
          -h             - human-readable report suppressed
          -v             - version number and help screen

        By default, ALL indexes in ALL filePro files are documented in
        two reports.  Arguments to the flags -f, -m and -i may be quoted
        strings of regular and shell filename generation meta characters
        defining patterns to match a subset of file names, qualifer names
        and/or indexes.  A null argument to -m excludes qualifier indexes.
        PFDATA, PFDIR, PFNAME, PFQUAL, PFDSK and PFINDX are recognized if
        set in the environment, but command line arguments can override
        PFNAME, PFQUAL and PFINDX (which holds index names or patterns).
"
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#  README  #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#

# Determine form of echo to use.
if [ `echo "x\c"` = "x" ]
then
    # Then the standard command will work just fine.
    ECHO="echo"
else
    # Otherwise we need to enable the 'backslash' processing.
    ECHO="echo -e"
fi
export ECHO
[ $tmpdir ] || tmpdir=/tmp
[ $instdir ] || . $HOME/utilset

#jmr 'whence' is not a function on Linux.
WHENCE=$instdir/whence
unset QUIET

while getopts f:m:i:qdsah flag 2>/dev/null
do case $flag in
     f) PFNAME=$OPTARG ;;
     m) PFQUAL=$OPTARG ; [[ -z $PFQUAL ]] && PFQUAL="No Qualifier" ;;
     i) PFINDX=$OPTARG ; PFINDX=${PFINDX#index*.} ;;
     q) QUIET=quiet ;;
     d) OUT=STD_OUT ; TEMP1=/tmp/irpt1.$$ ; TEMP2=/tmp/irpt2.$$
        [[ $REPORT1 != /dev/null ]] && REPORT1=$TEMP1
        [[ $REPORT2 != /dev/null ]] && REPORT2=$TEMP2 ;;
     s) REPORT2=/dev/null ;;
     a) QUIET=quiet
        OUT=STD_OUT ; TEMP1=/tmp/irpt1.$$ ; TEMP2=/tmp/irpt2.$$
        REPORT2=/dev/null
        [[ $REPORT1 != /dev/null ]] && REPORT1=$TEMP1
        [[ $REPORT2 != /dev/null ]] && REPORT2=$TEMP2 ;;
     h) REPORT1=/dev/null ;;
    \?) $ECHO "$Usage\c" 
    $ECHO "\n Press Enter to continue \c"; read key; exit 2 ;;
   esac
done
shift $(( $OPTIND - 1 ))
[[ $REPORT1 = /dev/null && $REPORT2 = /dev/null ]] && {
  $ECHO "\n  $PROG:  Incompatible options (-h and -s).\n" 
    $ECHO "\n Press Enter to continue \c"; read key; exit 2
}

trap '
  [[ -z $QUIET ]] && $ECHO $se$CN\n
  [[ -f $TEMP1 ]] && rm -f $TEMP1
  [[ -f $TEMP2 ]] && rm -f $TEMP2
  trap EXIT
  exit
' EXIT HUP INT QUIT TERM

# Linux doesn't recognize whence.  Rewrote to use whence function.
# use the fastest AWK available on the system:
[ -z "$AWK" ] && AWK=`$WHENCE mawk 2>/dev/null`
[ -z "$AWK" ] && AWK=`$WHENCE gawk 2>/dev/null`
[ -z "$AWK" ] && AWK=`$WHENCE nawk 2>/dev/null`
[ -z "$AWK" ] && AWK=`$WHENCE awk 2>/dev/null`

# See if any of PFPROG, PFDATA, & PFDIR are not in the environment;
# prefer PFPROG, PFDATA & PFDIR, but accept FPPROG, FPDATA or FPDIR.
# If any are missing, read /etc/default/fppath putting defaults for
# PFPROG, PFDATA & PFDIR in the array elements FP[1], FP[2] & FP[3]:
: ${PFPROG:=$FPPROG} ${PFDATA:=$FPDATA} ${PFDIR:=$FPDIR}
[[ -z $PFPROG || ( -z $PFDATA && -z $PFDIR ) ]] && {
  [[ -r /etc/default/fppath ]] && { typeset -i i=0
    while read ; do i=`expr $i + 1` ; FP[i]=$REPLY ; done </etc/default/fppath
  } || {
    $ECHO "\n  $PROG:  Can't read \"/etc/default/fppath\".\n"
    $ECHO "\n Press Enter to continue \c"; read key ; exit 2
  }
}
# See if the filePro programs directory can be found:
[[ -d ${PFPROG:=${FP[1]}}/fp ]] || {
  $ECHO "\n  $PROG:  Can't find the filePro Programs.\n" 
    $ECHO "\n Press Enter to continue \c"; read key; exit 2
}
# Assure the script is being run with "root" or "filepro" permissions:
[[ -w $PFPROG/fp/lib/errmsg ]] || {
  $ECHO "\n  $PROG:  Must be run by \"root\" or \"filepro\".\n" 
    $ECHO "\n Press Enter to continue \c"; read key; exit 2
}
# See if the filePro files directory can be found:
[[ -d ${PFDATA:=${FP[2]}}${PFDIR:=${FP[3]}}/filepro ]] || {
  $ECHO "\n  $PROG:  Can't find the filePro Files.\n" 
    $ECHO "\n Press Enter to continue \c"; read key; exit 2
}
[[ -n ${PFNAME:=$FPNAME} ]] && {
  cd $PFDATA$PFDIR/filepro
  for file in $PFNAME
  do [[ -r $file/map ]] && continue
     $ECHO "\n  $PROG:  \"$file\" is not a filePro file.\n" 
    $ECHO "\n Press Enter to continue \c"; read key; exit 2
  done
}

[[ -z $QUIET ]] && {
  $ECHO "\nInitializing . . . \c"
  # get terminal video control codes:
  : ${se:=$( tput rmso  )} # end standout mode
  : ${so:=$( tput smso  )} # start standout mode
  : ${up:=$( tput cuu1  )} # cursor up 1 line
  : ${CF:=$( tput civis )} # cursor off
  : ${CN:=$( tput cnorm )} # cursor on
}

# assign shell meta characters to PFNAME, PFQUAL or PFINDX not already set;
[[ -z ${PFNAME:=$FPNAME} ]] && PFNAME="*"
[[ -z ${PFQUAL:=$FPQUAL} ]] && PFQUAL="*"
[[ $PFQUAL = "No Qualifier" ]] && PFQUAL=""
[[ -z ${PFINDX:=$FPINDX} ]] && PFINDX="[A-P0-9]"
# find the indexes to be processed:
unset INDEXES

# get the filePro file names and their associated indexes so
# they sort properly if they are in more than one directory:
cd $PFDATA$PFDIR/filepro
indexes="$( echo $PFNAME/index$PFQUAL.[A-P0-9] )"
[[ $indexes = "$PFNAME/index$PFQUAL.[A-P0-9]" ]] && continue
for index in $PFNAME/index$PFQUAL.$PFINDX
do [[ -r $index ]] && INDEXES="$INDEXES $index"
done

INDEXES="$( echo $INDEXES )"
[[ $INDEXES = "$PFNAME/index$PFQUAL.[A-P0-9]" ]] && {
  $ECHO "\n\n  $PROG:  No index was found.\n" 
    $ECHO "\n Press Enter to continue \c"; read key; exit 0
}

# this automatically sorts the the indexes into the positional parameters:
# 01/22/01 - Linux doesn't support set -s. Experimented and found no difference
# in $INDEXES whether -s was used or not so removed it.
# set -s $INDEXES
set $INDEXES  
# and gets the number of them:
typeset -i NUM_INDEXES=$#

[[ -n $NAME_ONLY ]] && {
  (( NUM_INDEXES > 0 )) && {
    # Print just the names of all indexes:
    for index in $@ ; do $ECHO $index ; done |
    $AWK -F. '{if($NF~/^[A-P0-9]$/)print $NF}'
  } || { $ECHO "* NONE * " ; exit 2 ;}
  exit 0
}

(( NUM_INDEXES == 0 )) && {
  cd $PFPROG/fp/lib
  msg="\n\n  $PROG:\n\n  No index was found in:\t$PFDATA$PFDIR/filepro\n\n"
  $ECHO "\n Press Enter to continue \c"; read key; exit 0
}

# write to the terminal screen if not invoked with the -q argument:
[[ -n $QUIET ]] && FMT="" || {
  FMT="$so$up"
  $ECHO "$CF\n\nReporting on $so $NUM_INDEXES $se indexes . . .\n"
}

# get the full pathname of 'od' into the command we'll be using:
OD=`$WHENCE od 2>/dev/null`
CMD=" $OD -t u1 -A d -N 140 "

# ASCII printable characters:
# Test AWK to see if \ survives.
xx=`awk -v a="a\a" 'BEGIN {print length(a)}'`
# 06/24/01 - Changed from [ $xx = 2 ]. This failed on ATT unix.
[ "$xx" != 3 ] && {
  # \ did not survive must escape it.
  ascii="                                "
  ascii=${ascii}'!"#$%&'"'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO"
  ascii=${ascii}'PQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'
  } || {
  # \ did survive.
  ascii="                                "
  ascii=${ascii}'!"#$%&'"'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO"
  ascii=${ascii}'PQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'
  }

# feed the found indexes (by their full pathnames) to AWK and process them:
cd $PFDATA$PFDIR/filepro
for index in $@
do [[ -r $index ]] || continue
   # pipe the full pathname of the index to AWK:
   $ECHO $PFDATA$PFDIR/filepro/$index
done | $AWK -v se="$se" \
            -v CMD="$CMD" \
            -v FMT="$FMT" \
            -v RPT="$REPORT2" \
            -v ascii="$ascii" \
            -v DATE="$(/bin/date)" \
            -v NUM_INDEXES="$NUM_INDEXES" \
            -v tmp=/tmp/docindex \
            -v FPPATH="$PFDATA$PFDIR/filepro/" '
BEGIN {
  if ( FMT ) { 
    FIVE_PERCENT = int(NUM_INDEXES / 20) + 1 ; DONE = -5 ; abc = -2
    entertain()
  }
  fmt1 = "          Sort%d on Field=%3s - Len=%3d - %s - %s - %s\n"
  fmt2 = "          Sort%d on Field %3s - Len %3d - %s\n"
  fmt3 = "%s %s %s %s\n"
  eq = "=============================="; eq = eq eq eq eq
  if ( NUM_INDEXES != 1 ) es = "es"
  header = "Documenting " NUM_INDEXES " filePro Index" es " - " DATE
  xx = x = length(header)
  print substr(eq,1,x) "\n" header "\n" substr(eq,1,x)
} 
function entertain() {
  DONE += 5 ; abc += 3 ; BFMT = FMT "\n%" abc "s%d%% "
  printf( BFMT, "", DONE ) >"/dev/tty"
}
function ass_flds() {
  if ( ! alpha ) {
    ass_fld[11,186] = "@td" ; ass_fld[11,187] = "@cd" ; ass_fld[11,188] = "@ud"
    ass_fld[11,189] = "@cb" ; ass_fld[11,190] = "@ub" ; ass_fld[11,191] = "@bd"
    ass_fld[11,192] = "@t4" ; ass_fld[11,193] = "@c4" ; ass_fld[11,194] = "@u4"
    ass_fld[11,195] = "@b4"
    alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; j = 160 ; k = 15 ; n = 0
    for (i=1;i<=26;i++) {
      while ( 1 ) {
        ass_fld[k,j] = substr(alpha,i,1) n
        j += 32 ; if ( j > 224 ) { j = 0 ; k++ }
        n++ ; if ( n > 9 ) { n = 0 ; break }
      }
    }
  }
}
function Get_Map() {
  for ( name in fields ) { delete fields[name] ; delete edits[name] }
  MAP = FPPATH PFNAME "/map" ; FIELDS = 0 ; I = 1
  while ( getline Field < MAP > 0 ) {
    if ( FIELDS == 0 ) { if ( Field !~ /^map:/ ) I = 2
      for (i=1;i<=I;i++) getline Field < MAP
    }
    split(Field,z,":") ; fields[++FIELDS] = z[1] ; edits[FIELDS] = z[3]
    if ( z[1] ~ /^ *[A-Za-z][0-9]?\)/ ) { sub(/^ +/,"",z[1])
      if ( z[1] ~ /^[A-Za-z]\)/ ) sub(/\)/,"0",z[1])
      ass_name = toupper(substr(z[1],1,2))
      if ( ass_name in fields ) continue
      fields[ass_name] = fields[FIELDS]
    }
  }
  close( MAP )
  fields["@cd"] = "Creation Date"     ; fields["@cb"] = "Created By"
  fields["@ud"] = "Date Updated"      ; fields["@ub"] = "Updated By"
  fields["@bd"] = "Batch Update Date" ; fields["@td"] = "Today'"'"'s Date"
  fields["@c4"] = "Creation Date"     ; fields["@u4"] = "Date Updated"
  fields["@b4"] = "Batch Update Date" ; fields["@t4"] = "Today'"'"'s Date"
}
{
  if ( FMT && NR % FIVE_PERCENT == 0 ) entertain()
  x = split($0,y,"/")
  INDEX = substr(y[x],length(y[x]),1) ; rpt=colon=qual=Qual=comment= ""
  if ( PFNAME != y[x-1] ) {
    PFNAME = y[x-1]
    PFQUAL = y[x] ; gsub(/^index|\..$/,"",PFQUAL)
    if ( PFQUAL ) Qual = "Qualifier File:"
    printf( "\nFILENAME: %-14s        %s %s\n", PFNAME, Qual, PFQUAL )
    Get_Map()
  }
  for (i=0;i<=140;i++) offset[i] = ""
  # 02/18/01 - changed from hd to od command which is recognized by Linux.
  # read the 1st 140 bytes of the index with the od command:
  cmd = "<" $0 CMD
  while ( cmd | getline > 0 ) {
    if ( NF == 1 ) continue
    os = $1 + 0 ; for (i=2;i<=17;i++) offset[os++] = $i + 0
  }
  close( cmd )
  if ( INDEX ~ /^[A-P]$/ ) IND = "AUTO" ; else IND = "DEMAND"
  # v4.1 automatic and demand indexes have the same magic number;
  # v4.5 demand indexes have that same magic number:
  if ( offset[0] == 49 && offset[1] == 201 ) {
    if ( IND == "DEMAND" ) {
      # . . . this is just a wild guess:
      if ( offset[103] == 1 ) VERSION = "4.1"
      else if ( offset[103] == 0 ) VERSION = "4.5"
      else VERSION = "4.x"
    }
    else VERSION = "4.1"
    num_recs = offset[94]
    for (os=95;os<=97;os++) num_recs = num_recs + ( offset[os] * 256 )
    os = 18
  }
  else {
    VERSION = "4.5"
    num_recs = offset[16]
    for (os=17;os<=19;os++) num_recs = num_recs + ( offset[os] * 256 )
    num_recs -= 1
    if ( ASCII[49] != 1 )
      for (as=32;as<=126;as++) ASCII[as] = substr(ascii,as,1) 
    for (os=92;os<=140;os++) comment = comment ASCII[offset[os]]
    os = 24
  }
  printf( "\n   INDEX: %s  %s\n", y[x], "[" VERSION "]" )
  for (sort=1;sort<=8;sort++) {
    if ( rpt ) colon = ":"
    if ( offset[os] || offset[os+1] ) {
      field_num = offset[os] + ( 256 * offset[os+1] )
      if ( field_num > 999 ) { ass_flds()
        field_num = ass_fld[offset[os+1],offset[os]]
      }
      if ( ! field_num ) field_num = "< Dummy Field >"
      field_len = offset[os+4] + ( 256 * offset[os+5] )
      if ( offset[os+6] ) { AD = "Des" ; ad = "d" }
      else { AD = "Asc" ; ad = "a" }
      if ( edits[field_num] == "" ) edits[field_num] = "*"
      if ( field_num != "< Dummy Field >" )
        printf( fmt1, sort, field_num, field_len, AD, edits[field_num], fields[field_num] )
      else printf( fmt2, sort, field_num, field_len, AD )
      rpt = rpt colon field_num "," field_len "," ad
    }
    os += 8
  }
  if ( num_recs != 1 ) S = "s" ; else S = ""
  printf( "          Built on %d record%s.\n", num_recs, S )
  if ( comment ) print " Comment:", comment
  if ( y[x] ~ /^index.+\./ ) {
    sub(/^index/,"",y[x]) ; sub(/\..+$/,"",y[x]) ; qual = y[x]
  }
  # do not list indexes sorted on dummy fields in report2:
  if ( rpt !~ /Dummy/ )
    printf( fmt3, PFNAME, INDEX, rpt, qual ) > RPT
}
END {
  BFMT = FMT "\n%" abc "s%d%% " se "\n\nDone . . .\n\n"
  if ( FMT ) printf( BFMT, "", 100 ) >"/dev/tty"
  print "\n" substr(eq,1,xx)
}' >$REPORT1

[[ $OUT = STD_OUT ]] && {
  [[ -r $TEMP1 ]] && cat $TEMP1
  [[ -r $TEMP1 && -r $TEMP2 ]] && $ECHO "\f"
  [[ -r $TEMP2 ]] && cat $TEMP2
}

# docname=index$docname`$ECHO $PFDIR | tr "/" "_"`.doc
# If run from instutil menu then instutil will be set otherwise use /tmp
[ $instutil ] || instutil=/tmp
# If $PFDATA$PFDIR/index.doc exists then check to see if $PFDATA$PFDIR/report1 
# and $PFDATA$PFDIR/index.doc are different.  If so save old report.
[ -f $PFDATA$PFDIR/index.doc ] && {
  sed -n "5,$ p" < $PFDATA$PFDIR/report1 > /tmp/dif1
  sed -n "5,$ p" < $PFDATA$PFDIR/index.doc > /tmp/dif2
  dif=`diff /tmp/dif1 /tmp/dif2`
  rm -f /tmp/dif1 /tmp/dif2
  # if so move existing index.doc to index.doc#
  [ -n "$dif" ] && {
    dif=$PFDATA$PFDIR/index.doc
    while [ -f $dif ]
    do
      dif=$dif\#
    done
    $ECHO
    $ECHO "Original $PFDATA$PFDIR/index.doc saved in $dif"
    mv -f $PFDATA$PFDIR/index.doc $dif
    }
  }
# Now copy $PFDATA$PFDIR/report1 
cp -f $PFDATA$PFDIR/report1 $PFDATA$PFDIR/index.doc
$ECHO
$ECHO "Index documentation saved in $PFDATA$PFDIR/index.doc"
# $ECHO "\nPress Enter to continue. \c"
# read key
# Let docindex fall through to reindex - jmr
# exit 0

# 'docindex' is a joint project by:
# Marc Parns - MarcParns@aol.com, and
# Bob Stockler - bob@trebor.iglou.com

# report1 is in this format, for documentation:
#    ============================================================
#    Documenting 6 filePro Indexes - Fri Apr 17 17:17:17 EDT 1998
#    ============================================================
#
#    FILENAME: address
#
#     INDEX: index.0  [4.x]
#            Sort1 on Field   2 - Len   4 - Des - Category
#            Sort2 on Field   5 - Len  18 - Asc - Sort Name
#            Built on 60 records.
#
#     INDEX: index.1  [4.x]
#            Sort1 on Field < Dummy Field > - Len  15 - Asc
#            Sort1 on Field < Dummy Field > - Len   9 - Des
#            Built on 60 records.
#
#     INDEX: index.A  [4.1]
#            Sort1 on Field   5 - Len  18 - Asc - Sort Name
#            Built on 59 records.
#
#     INDEX: index.B  [4.5]
#            Sort1 on Field A0) - Len   5 - Asc - a) Account #
#            Sort2 on Field   5 - Len  18 - Asc - Sort Name
#            Built on 64 records.
#
#     INDEX: indexqual.A  [4.1]
#            Sort1 on Field   5 - Len  18 - Asc - Sort Name
#            Built on 106 records.
#
#     INDEX: indexqual.B  [4.5]
#            Sort1 on Field A0) - Len   5 - Asc - a) Account #
#            Sort2 on Field   5 - Len  18 - Asc - Sort Name
#            Built on 106 records.
#
# report2 is in a format suitable for reading by a script
# to hand information to 'dxmaint' to rebuild an index:
#
#  4.x address 0 2,4,d:5,18,a
#  4.1 address A 5,18
#  4.5 address B A0),5:5,18
#  4.1 address A 5,18 qual
#  4.5 address B A0),5:5,18 qual
#
#!/bin/ksh
# @(#) rebuild all indexes
# Modified 10/31/00 by Jerry Rains to be used in Installation Utilities Menu.
#     1) Set REPORT2 explicitly to $PFDATA$PFDIR/report2
#     2) Set MENU2 explicitly to $PFDATA$PFDIR/rbldindex.  Hardcoding to 
#        rbldindex allowed me to use this reindex.script with the new install.
#     3) Eliminated top.menu, which was hard coded to /etc/default/fppath
#     and set header from environment.

REPORT2=$PFDATA$PFDIR/report2
MENU2=$PFDATA$PFDIR/rbldindex
# If rbldindex exists save it.
[ -f $MENU2 ] && {
  dif=$MENU2
  while [ -f $dif ]
  do
    dif=$dif\#
  done
  $ECHO "\nSaving rbldindex as $dif"
  $ECHO "\nTo rebuild indexes run $MENU2"
  mv $MENU2 $dif
  } 
$ECHO "PFPROG=$PFPROG
PFDIR=$PFDIR
PFDATA=$PFDATA
PFDSK=$PFDSK
export PFPROG PFDIR PFDATA PFDSK
" >$MENU2
# 02/18/01 - Linux doesn't like @([0-9]).  Removed @().
while read filename index args qualifier
do [ $index = [0-9] ] && ALL="-a" || ALL=""
   [[ -n $qualifier ]] && QUAL="-m $qualifier" || QUAL=""
$ECHO \$PFPROG/fp/dxmaint $filename -e -o$index $ALL $QUAL -rf $args -h $filename  >>$MENU2
done <$REPORT2
chown filepro $MENU2
chmod 755 $MENU2
$ECHO "\nPress Enter to continue. \c"
read key

# EOF 'docindex'
