If you want to do this from a Routine or the TCL environment, search the forum for the STATUS statement; it's a much cleaner solution.
Code: Select all
#!/bin/sh
# History
# Date Programmer Version Details of Modification
# ---------- ------------- ------- ---------------------------------------
# 07/08/2004 Ray Wurlod 1.0 Initial coding
#
# Verify that filename passed as argument
if [ $# -ne 1 ]
then
echo Usage: $0 hashedfilename
exit 1
fi
# Verify that filename passed as argument is readable
filename=$1
if [ ! -r $filename ]
then
echo \"${filename}\" is not accessible.
exit 1
fi
# Determine whether dynamic or static hashed file
if [ -d $filename ]
then
if [ -r $filename/.Type30 ]
then
testfile=$filename/DATA.30
filetype='Dynamic hashed file '
else
echo $filename is a directory, not a hashed file
exit 1
fi
else
testfile=$filename
filetype='Static hashed file '
fi
# Grab the relevant part of the file header
# Note that this form of od is specifically for Solaris - you may need
# to adjust for other forms of UNIX, mainly the cut columns.
magic=`od -N4 -x $testfile | cut -c14-15`
# This statement is for testing purposes.
# echo $magic
# Now report our conclusions.
if [ $magic -eq '01' ]
then
echo $filetype \"${filename}\" uses 32-bit pointers.
elif [ $magic -eq '02' ]
then
echo $filetype \"${filename}\" uses 64-bit pointers.
else
echo \"${filename}\" is not a hashed file.
exit -1
fi
exit 0