Results 1 to 5 of 5

Thread: SyntaxError: invalid syntax

  1. #1
    Join Date
    Jan 2013
    Beans
    4

    [SOLVED]SyntaxError: invalid syntax

    Code:
    #!/usr/local/bin/python
    until phew.py; do
            echo "'phew.py' crashed with exit code $?. Restarting..." >&2
            sleep 1
    done
    Code:
     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
    Code:
    /usr/local/bin/
    I've done
    Code:
    which python
    and outputs
    Code:
    /usr/local/bin/python
    Last edited by xenazfire; January 15th, 2013 at 07:56 PM.

  2. #2
    Join Date
    Apr 2009
    Location
    Germany
    Beans
    2,134
    Distro
    Ubuntu Development Release

    Re: SyntaxError: invalid syntax

    shell is not python
    run your shell script from a shell, e.g. bash
    Code:
    #/bin/bash
    ...
    for the until line to work phew.py must be in a directory in the PATH variable
    Last edited by MadCow108; January 15th, 2013 at 07:25 PM.

  3. #3
    Join Date
    Jan 2013
    Beans
    4

    Re: SyntaxError: invalid syntax

    Quote Originally Posted by MadCow108 View Post
    shell is not python
    run your shell script from a shell, e.g. bash
    Code:
    #/bin/bash
    ...
    for the until line to work phew.py must be in a directory in the PATH variable
    EDIT:
    Refer to post #4
    Last edited by xenazfire; January 15th, 2013 at 07:33 PM.

  4. #4
    Join Date
    Jan 2013
    Beans
    4

    Re: SyntaxError: invalid syntax

    UPDATE:
    Copied the python files to
    Code:
    /usr/local/bin/
    run
    Code:
    nohup ./phew.sh &
    and it outputs
    Code:
    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...

  5. #5
    Join Date
    Jan 2013
    Beans
    4

    Re: SyntaxError: invalid syntax

    Solved!
    Placed on the first line on each *.py files:
    Code:
    #!/usr/local/bin/python
    Thanks!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •