#!/bin/csh
#
#  This shell script removes all lines above 'CALL -151' and all
#  lines below 'E00G' in an executioner converted Usenet posting.
#  It also appends 2 linefeeds after 'E00G' and proceeds to convert
#  all linefeeds to carriage returns which apple 2's prefer.  
#  Wildcard filenames are allowed with each extracted file having
#  a '.exec' tail added.  
#  The shell script is a kludge, but it works fine.  
#  Tested with an Apple //c using kermit and xmodem on a microvax
#  running Ultrix 2.0-1.
#  Written by Paul Nakada   This program is free.  Please distribute freely
#

if ($#argv == 0) then
    echo 'usage: stripexec filename'
    exit
endif

foreach file ($argv)
   set newfile=`echo $file .exec | tr -d ' '`
   echo '...stripping header and trailer from' $file '...'
   echo '... placing extracted file in' $newfile '...'
   awk '/CALL/, /E00G/ { print $0 ; if ($0 == "E00G") printf ("\n\n"); }'\
$file | tr '\012' '\015' > $newfile
end
