PDA

View Full Version : SyntaxError: invalid syntax



xenazfire
January 15th, 2013, 07:20 PM
#!/usr/local/bin/python
until phew.py; do
echo "'phew.py' crashed with exit code $?. Restarting..." >&2
sleep 1
done


File "./phew.sh", line 2
until phew.py; do
^
SyntaxError: invalid syntax

Hi, I need help in fixing this error. Please help. Should I place the python files in the same directory as this bash file? Currently I place this bash file in my root folder and the python files in
/usr/local/bin/

I've done

which python
and outputs

/usr/local/bin/python

MadCow108
January 15th, 2013, 07:22 PM
shell is not python
run your shell script from a shell, e.g. bash

#/bin/bash
...

for the until line to work phew.py must be in a directory in the PATH variable

xenazfire
January 15th, 2013, 07:27 PM
shell is not python
run your shell script from a shell, e.g. bash

#/bin/bash
...

for the until line to work phew.py must be in a directory in the PATH variable

EDIT:
Refer to post #4

xenazfire
January 15th, 2013, 07:32 PM
UPDATE:
Copied the python files to

/usr/local/bin/
run

nohup ./phew.sh &
and it outputs

from: can't read /var/mail/random
from: can't read /var/mail/time
from: can't read /var/mail/settings
from: can't read /var/mail/rest
/usr/local/bin/phew.py: line 8: syntax error near unexpected token `('
/usr/local/bin/phew.py: line 8: `def autoScan():'
'phew.py' crashed with exit code 2. Restarting...

xenazfire
January 15th, 2013, 07:59 PM
Solved!
Placed on the first line on each *.py files:

#!/usr/local/bin/python

Thanks!