Subject: (2.1) BASH tips |
---|
If you are using a Unix who's /bin/sh is a hardlink to bash, you'll find problems using nntpsend. nntpsend uses a variable named PPID, which is a read-only variable in BASH. You'll get errors that look like this: sh: PPID: read-only variable You can fix it using the the following patch: *** nntpsend~ Thu Aug 12 03:36:16 1993 --- nntpsend Sat Oct 23 15:54:11 1993 *************** *** 1,4 **** ! #! /bin/sh ## $Revision: 2.34 $ ## Send news via NNTP by running several innxmit processes in the background. ## Usage: --- 1,4 ---- ! #!/usr/local/bin/bash ## $Revision: 2.34 $ ## Send news via NNTP by running several innxmit processes in the background. ## Usage: *************** *** 130,140 **** chmod 0660 ${LOG} exec >>${LOG} 2>&1 fi ! PPID=$$ ! echo "${PROGNAME}: [${PPID}] start" ## Set up environment. ! export BATCH PROGNAME PPID INNFLAGS ## Loop over all sites. cat ${INPUT} | while read SITE HOST MAXSIZE FLAGS; do --- 130,140 ---- chmod 0660 ${LOG} exec >>${LOG} 2>&1 fi ! CPID=$$ ! echo "${PROGNAME}: [${CPID}] start" ## Set up environment. ! export BATCH PROGNAME CPID INNFLAGS ## Loop over all sites. cat ${INPUT} | while read SITE HOST MAXSIZE FLAGS; do *************** *** 240,246 **** fi ## Start sending this site in the background. ! export SITE HOST LOCKS BATCHFILE PROGNAME PPID SIZE TMPDIR sh -c ' BATCHFILE=${HOST}.nntp LOCK=${LOCKS}/LOCK.${HOST} --- 240,246 ---- fi ## Start sending this site in the background. ! export SITE HOST LOCKS BATCHFILE PROGNAME CPID SIZE TMPDIR sh -c ' BATCHFILE=${HOST}.nntp LOCK=${LOCKS}/LOCK.${HOST} *************** *** 247,253 **** trap "rm -f ${LOCK} ; exit 1" 1 2 3 15 shlock -p $$ -f ${LOCK} || { WHY="`cat ${LOCK}`" ! echo "${PROGNAME}: [${PPID}:$$] ${HOST} locked ${WHY} `date`" exit } if [ -f ${SITE}.work ] ; then --- 247,253 ---- trap "rm -f ${LOCK} ; exit 1" 1 2 3 15 shlock -p $$ -f ${LOCK} || { WHY="`cat ${LOCK}`" ! echo "${PROGNAME}: [${CPID}:$$] ${HOST} locked ${WHY} `date`" exit } if [ -f ${SITE}.work ] ; then *************** *** 254,259 **** --- 254,260 ---- cat ${SITE}.work >>${BATCHFILE} rm -f ${SITE}.work fi + if [ -s ${SITE} ] ; then mv ${SITE} ${SITE}.work if ctlinnd -s -t30 flush ${SITE} ; then cat ${SITE}.work >>${BATCHFILE} *************** *** 260,273 **** rm -f ${SITE}.work test -n "${SIZE}" && shrinkfile -s${SIZE} -v ${BATCHFILE} if [ -s ${BATCHFILE} ] ; then ! echo "${PROGNAME}: [${PPID}:$$] begin ${HOST} `date`" ! echo "${PROGNAME}: [${PPID}:$$] innxmit ${INNFLAGS} ${HOST} ..." eval innxmit ${INNFLAGS} ${HOST} ${BATCH}/${BATCHFILE} ! echo "${PROGNAME}: [${PPID}:$$] end ${HOST} `date`" else rm -f ${BATCHFILE} fi fi rm -f ${LOCK} ' & sleep 5 --- 261,275 ---- rm -f ${SITE}.work test -n "${SIZE}" && shrinkfile -s${SIZE} -v ${BATCHFILE} if [ -s ${BATCHFILE} ] ; then ! echo "${PROGNAME}: [${CPID}:$$] begin ${HOST} `date`" ! echo "${PROGNAME}: [${CPID}:$$] innxmit ${INNFLAGS} ${HOST} ..." eval innxmit ${INNFLAGS} ${HOST} ${BATCH}/${BATCHFILE} ! echo "${PROGNAME}: [${CPID}:$$] end ${HOST} `date`" else rm -f ${BATCHFILE} fi fi + fi rm -f ${LOCK} ' & sleep 5 *************** *** 275,278 **** wait rm -f ${INPUT} ! echo "${PROGNAME}: [${PPID}] stop" --- 277,280 ---- wait rm -f ${INPUT} ! echo "${PROGNAME}: [${CPID}] stop"------------------------------ [Last Changed: $Date: 1997/09/23 01:25:52 $ $Revision: 2.34 $] [Copyright: 1997 Heiko Rupp, portions by Tom Limoncelli, Rich Salz, et al.] |