problem with starting script

Hi all..

My problem - I am used this script kontrola.sh for restart crashing proces but problem..

Code:
#!/bin/sh

GAMEDIR="/home/game"
LOG="$GAMEDIR/corerestart.log"

PIDAUTH=`ps aux | grep auth | grep -v grep | awk '{print $2;}'`
if [ "x$PIDAUTH" != "x" ];
then
echo "`date +%d.%m.%Y-%H:%M:%S` :: AUTH SERVER je ok! PID: $PIDAUTH" >> $LOG
else
echo "`date +%d.%m.%Y-%H:%M:%S` :: AUTH CORE spadlo" >> $LOG
echo "`date +%d.%m.%Y-%H:%M:%S` :: Startuji AUTH ..." >> $LOG
cd $GAMEDIR/auth && ./auth &

fi

problem..

Code:
: not found
: not found
kontrola.sh: 15: Syntax error: "fi" unexpected (expecting "then")

I check several discussions, but no information did not help, move, "then" or "fi" did not work, the system is FreeBSD 8.2 64bit

help please

or I would anyone written a similar script for python ?


sorry for my english.. and thanks all
 
ah sorry i am posted older script, my is this..

Code:
#!/bin/sh

SLOZKA="/home/test"
LOG="$SLOZKA/restart.log"

PIDWEB=`ps aux | grep web | grep -v grep | awk '{print $2;}'`
if [ "x$PIDWEB" != "x" ];
then
echo "`date +%d.%m.%Y-%H:%M:%S` :: WEB SERVER je ok! PID: $PIDWEB" >> $LOG
else
echo "`date +%d.%m.%Y-%H:%M:%S` :: WEB spadl" >> $LOG
echo "`date +%d.%m.%Y-%H:%M:%S` :: Startuji WEB ..." >> $LOG
cd $SLOZKA/web && ./web &

fi
 
If you need to have that game up and running all the time, another approach is to use a supervise process for it like svscan, monit, etc.

However, writing a script for it is fun too :).
 
R3plik4tor said:
ah sorry i am posted older script, my is this..

Code:
#!/bin/sh

SLOZKA="/home/test"
LOG="$SLOZKA/restart.log"

PIDWEB=`ps aux | grep web | grep -v grep | awk '{print $2;}'`
if [ "x$PIDWEB" != "x" ];
then
echo "`date +%d.%m.%Y-%H:%M:%S` :: WEB SERVER je ok! PID: $PIDWEB" >> $LOG
else
echo "`date +%d.%m.%Y-%H:%M:%S` :: WEB spadl" >> $LOG
echo "`date +%d.%m.%Y-%H:%M:%S` :: Startuji WEB ..." >> $LOG
cd $SLOZKA/web && ./web &

fi

And does it not run for you? I tried and it works here just perfectly.
Anyways you might use xtrace and verbose flags with sh to see some more details:
Code:
#!/bin/sh
set -xv

<your code follows>
 
problem resolved.. PIDWEB is problem, running proces is "web" but WEB no.. problem is W or w .. thanks all and bye
 
Back
Top