@@ -23,23 +23,53 @@
# did we get proper arguments?
test "$1" -a "$2" || exit 1
+DD=`which dd 2>/dev/null`
+if test $? -ne 0 ; then
+ echo dd not found.
+ exit 1
+fi
+
+OD=`which od 2>/dev/null`
+if test $? -ne 0 ; then
+ echo od not found.
+ exit 1
+fi
+
+EXPR=`which expr 2>/dev/null`
+if test $? -ne 0 ; then
+ echo expr not found.
+ exit 1
+fi
+
+CP=`which cp 2>/dev/null`
+if test $? -ne 0 ; then
+ echo cp not found.
+ exit 1
+fi
+
+PRINTF=`which printf 2>/dev/null`
+if test $? -ne 0 ; then
+ echo printf not found.
+ exit 1
+fi
+
sum=0
# find out the file size
-x=`dd if="$1" bs=1 count=1 skip=2 2>/dev/null | od -t u1 -A n`
+x=`${DD} if="$1" bs=1 count=1 skip=2 2>/dev/null | ${OD} -t u1 -A n`
#size=`expr $x \* 512 - 1`
size=$(( $x * 512 - 1 ))
# now get the checksum
-nums=`od -A n -t u1 -v "$1"`
+nums=`${OD} -A n -t u1 -v "$1"`
for i in ${nums}; do
# add each byte's value to sum
- sum=`expr $sum + $i`
+ sum=`${EXPR} $sum + $i`
done
sum=$(( $sum % 256 ))
sum=$(( 256 - $sum ))
# and write the output file
-cp "$1" "$2"
-printf "\\$sum" | dd of="$2" bs=1 count=1 seek=$size conv=notrunc 2>/dev/null
+${CP} "$1" "$2"
+${PRINTF} "\\$sum" | ${DD} of="$2" bs=1 count=1 seek=$size conv=notrunc 2>/dev/null