2

i have the following shell script-

#!/bin/bash
echo "enter the full path of script";
read path;
while true
 ps aux | grep -v grep | grep -q $path || ( nohup php -f $path & )
done

I am executing in following way -

bash test.sh
enter the full path of script
php_test.php
test.sh: line 7: syntax error near unexpected token `done'
test.sh: line 7: `done'

there is a php_test.php in the same directory as the present one. PLease help. Thanks in advance.

Ignacio Vazquez-Abrams
803k160 gold badges1.4k silver badges1.4k bronze badges
asked Jan 10, 2011 at 9:11
2
  • This question is not related to php. Commented Jan 10, 2011 at 9:13
  • Also escape $path with double quotes to prevent spaces in the variable to have bash consider it as two arguments after expansion. Commented Jan 10, 2011 at 9:17

1 Answer 1

4

From help while:

while: while COMMANDS; do COMMANDS; done

You're missing the do.

while true
do
 ...
done
answered Jan 10, 2011 at 9:15

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.