Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #70498

Re: Strange syntax error, occurs only when script is executed directly

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <mail@timgolden.me.uk>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:error': 0.03; 'syntax': 0.04; 'explicitly': 0.05; 'interpreter': 0.05; 'root': 0.05; '#if': 0.07; 'subject:script': 0.09; 'python': 0.11; 'def': 0.12; '10:05': 0.16; 'bind': 0.16; 'fine.': 0.16; 'from:addr:timgolden.me.uk': 0.16; 'from:name:tim golden': 0.16; 'message-id:@timgolden.me.uk': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'subject:when': 0.16; 'tjg': 0.16; 'unbind': 0.16; 'unexpected': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'error': 0.23; 'received:192.168.100': 0.24; '(or': 0.24; 'script': 0.25; 'header :In-Reply-To:1': 0.27; 'idea': 0.28; 'skip:( 20': 0.30; 'lines': 0.31; 'class': 0.32; 'skip:_ 10': 0.34; 'version': 0.36; 'machine.': 0.36; 'error.': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'first': 0.61; 'from:addr:mail': 0.83; 'pardon': 0.84
Date Tue, 22 Apr 2014 11:35:43 +0100
From Tim Golden <mail@timgolden.me.uk>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.0
MIME-Version 1.0
To python-list@python.org
Subject Re: Strange syntax error, occurs only when script is executed directly
References <535644A4.6060901@rece.vub.ac.be>
In-Reply-To <535644A4.6060901@rece.vub.ac.be>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.9432.1398162948.18130.python-list@python.org> (permalink)
Lines 54
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1398162948 news.xs4all.nl 2915 [2001:888:2000:d::a6]:56512
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:70498

Show key headers only | View raw


On 22/04/2014 11:29, Antoon Pardon wrote:
> I am workin on a solaris 11 machine. The python version is 2.7.6
> path to python is /opt/local/bin/python.
> 
> These are the 15 first lines of the script:
> 
> #! /opt/local/bin/python
> 
> class vslice(object):
> 
>         def __init__(self, fun):
>                 self.fun = fun
> 
>         def __getitem__(self, inx):
>                 if not isinstance(inx, tuple):
>                         inx = inx,
>                 #if
>                 return self.fun(*inx)
>         #end __getitem__
> #end __vslice__
> 
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> 
> Now if I execute the script by explicitly calling the interpreter
> everything works fine.
> 
> # /opt/local/bin/python /usr/local/bin/ldapwatch /opt/local/log/openldap.log | head
> Apr 21 15:12:38 conn=110982 fd=125 ACCEPT from IP=10.0.59.10:46238 (IP=10.0.128.65:389)
> Apr 21 15:12:38 conn=110982 op=0 BIND dn="uid=anonymous,ou=local,ou=people,o=global" method=128
> Apr 21 15:12:38 conn=110982 op=0 BIND dn="uid=anonymous,ou=local,ou=people,o=global" mech=SIMPLE ssf=0
> Apr 21 15:12:38 conn=110982 op=0 RESULT tag=97 err=0 text=
> Apr 21 15:12:38 conn=110982 op=1 SRCH base="ou=people,o=global" scope=2 deref=0 filter="(uid=anonymous)"
> Apr 21 15:12:38 conn=110982 op=1 SEARCH RESULT tag=101 err=0 nentries=1 text=
> Apr 21 15:12:38 conn=110982 op=2 UNBIND
> Apr 21 15:12:38 conn=110982 fd=125 closed
> ====
> Apr 21 15:12:57 conn=110983 fd=125 ACCEPT from IP=10.1.28.235:39616 (IP=10.0.128.65:389)
> 
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> 
> 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 have no idea what is going on here. The persmision for /usr/local/bin/ldapwatch look fine:
> # ls -l /usr/local/bin/ldapwatch -rwxr-xr-x 1 root root 2092 Apr 22 10:05 /usr/local/bin/ldapwatch

Look for a dodgy line-feed / cr (or some other non-visible control
character) at the end of the shebang line?

TJG

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Strange syntax error, occurs only when script is executed directly Tim Golden <mail@timgolden.me.uk> - 2014-04-22 11:35 +0100

csiph-web