problems with sh after upgrade to 4.7

Gunnar Flygt gunnar.flygt at sr.se
Fri Feb 3 03:24:09 PST 2006


After upgrade from 4.6.2-RELEASE to 4.7-RELEASE I've got problems
with a shellscript that I have on one of my machines. The script
(which I've taken over from a far better shellprogammer) looks as follows:

#!/bin/sh

RTSPCONTROL="/usr/local/etc/rc.d/rtspproxy.sh"
cd `dirname $0`
cd ../..
PREFIX=/usr/local

case $1 in
        start)  echo -n ' rtspproxy'
                RTSPPROXY=${PREFIX}/sbin/rtspproxy
                PID_FILE=/var/run/rtspproxy.pid
                [ -x ${RTSPPROXY} ] && ${RTSPPROXY} > /dev/null & && echo $! > $ {PID_FILE}
                ;;
        stop)   if [ -f /var/run/rtspproxy.pid ]; then
                        kill `cat /var/run/rtspproxy.pid`
                        rm /var/run/rtspproxy.pid
                fi
                ;;
        check)
                for pidfile in `find /var/run -name 'rtspproxy.pid'`
                do
                        if ! kill -0 `head -1 $pidfile` > /dev/null ;then
                        echo "$pidfile process is dead! Restarting..."
                        logger -p daemon.err -t rtspproxy.sh "$pidfile process is dead! Restarting..."
                        ARGS=start
                        rm -f $pidfile
                        ${RTSPCONTROL} ${ARGS}
                        fi
                done
                ;;


esac

The problem line is line 12:
 [ -x ${RTSPPROXY} ] && ${RTSPPROXY} > /dev/null & && echo $! > $ {PID_FILE}

When I run `/usr/local/etc/rc.d/rtspproxy.sh start I get this error

/usr/local/etc/rc.d/rtspproxy.sh: 12: Syntax error: "&&" unexpected

The script starts the file and redirects the output from rtspproxy
(the PID) to the PID_FILE so that the check part can use it later.

Since my knowledge in shellscripting is not enough to rewrite the script,
I ask for help here.

-- 
Gunnar Flygt
OPC Data
Sveriges Radio




More information about the freebsd-questions mailing list