1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#! /bin/sh
# this is just a simple script to run the one line sed
# command to strip off the NNTP Posting Header that
# my ISP's newsfeed doesn't like.
# this could be written as a one liner
# sed -e CMD $1 > $2
COMMAND=$0
ETCDIR=/etc/suck # location of sucknewsrc* and killfile*
GETNEWSCONF=${ETCDIR}/get-news.conf # defaults for this script
if [ $# -ne 2 ]; then
echo
echo "Usage `basename $0` infile outfile <RETURN>"
echo
exit 2
fi
SEDCMD=`grep ^sedcmd: ${GETNEWSCONF} \
| awk '{gsub(" ","");print}' | cut -c8-`
OUTFILE=$2
INFILE=$1
SM=/usr/lib/news/bin/sm
if [ -x ${SM} -o -f ${INFILE} ]; then
if [ -x ${SM} ]; then
# using inn2.3, we need to use sm, which translates inn 2.3's concept
# of an article token into something which we can use. *sigh*. And
# the infile isn't really a file, it's a mangled token. Kludge.
INFILE=`echo ${INFILE} | sed "s,.*/,,"`
${SM} ${INFILE} | sed "1,/^$/{
${SEDCMD}
}" > ${OUTFILE}
else
sed "1,/^$/{
${SEDCMD}
}" ${INFILE} > ${OUTFILE}
fi
if [ $? -ne 0 ]; then
echo "Error"
exit 255
fi
else
echo "$1 does not exist"
exit 127
fi
|