Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #70499
| From | "Frank Millman" <frank@chagford.com> |
|---|---|
| Subject | Re: Strange syntax error, occurs only when script is executed directly |
| Date | 2014-04-22 12:42 +0200 |
| References | <535644A4.6060901@rece.vub.ac.be> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.9433.1398163357.18130.python-list@python.org> (permalink) |
"Antoon Pardon" <antoon.pardon@rece.vub.ac.be> wrote in message
news:535644A4.6060901@rece.vub.ac.be...
>I am workin on a solaris 11 machine. The python version is 2.7.6
> path to python is /opt/local/bin/python.
>
[...]
>
> Now if I execute the script by explicitly calling the interpreter
> everything works fine.
>
[...]
>
> However if I call the script directly and want the #! line do its work I
> get the following error.
>
> # /usr/local/bin/ldapwatch /opt/local/log/openldap.log | head
> /usr/local/bin/ldapwatch: line 3: syntax error near unexpected token `('
> /usr/local/bin/ldapwatch: line 3: `class vslice(object):'
>
I had something similar and it turned out that my script had 'CRLF' line
endings instead of 'LF' only, and this caused the problem. I believe that
the problem has nothing to do with python, but with how the shell interprets
the '#!' line.
My editor allows me to re-save a file using a different format, so I saved
it as 'unix', reran it, and it worked.
HTH
Frank Millman
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Strange syntax error, occurs only when script is executed directly "Frank Millman" <frank@chagford.com> - 2014-04-22 12:42 +0200
csiph-web