#!/bin/sh
# Filename: screenfix.script -- a shell script
#
# Author: Kevin FitzGerrell
# Comments to: kfitz@gci.net or fitzgerrell@yahoo.com
#
# Usage: Copy screenfix.script to target directory and make it
# executable and then run it. Assumption is that substitution lists
# and the generic overlays they fill are in the same directory.
#
# Description: Run from the directory containing substitution lists
# and generic overlays, this script will locate substitution list files
# and their generic overlays and will replace the substitution list
# list with a graphic overlay file of the same name.
# The script uses d_edit50 to dump and upload the screen files.
# The original substitution lists are saved with a .list suffix.
# Running this script on a directory with a large number of files
# to be converted will be slow. Rerunning it on a directory in which
# files have been converted or partially converted will produce odd
# results because it will generate a new graphic overlay for each
# "filename".list file.
#
# Created files: temporary files tmp2 and tmp3 are created and removed
# at the end of program execution. A new file with a .list extension
# will be created for each substitution list. A temporary file with a
# .dmp and another with a .dmp.new extension will be created and removed
# for each substitution list.
# generate file list of all substitution list files in tmp2.
grep '^subs:' * | awk -F: '{print $1}' | sort -u > tmp2
for file in `cat tmp2` ;
do
# copy substitution list file to "file".list
cp $file $file.list
# copy the appropriate generic overlay to "file"
cp `grep '^subs:' $file.list | awk -F: '{print $2}'` $file
# using d_edit50 generate file dump
/usr/fox/wp/bin/tools/d_edit50 -dump $file
# generate sed search and replace commands from substitution list
grep '=' $file.list | sed 's#.*#s/&/#' | sed 's#=#/#' > tmp3
# replace generic variable references with actual C:B.P references
sed -f tmp3 $file.dmp > $file.dmp.new
mv $file.dmp.new $file.dmp
# upload resulting file
/usr/fox/wp/bin/tools/d_edit50 -upload $file
# remove dump file
rm $file.dmp ;
done
# remove work files
rm tmp2
rm tmp3
               (
geocities.com/fitzgerrell)