Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'received:134': 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; 'subject:when': 0.16; 'unbind': 0.16; 'unexpected': 0.16; 'fix': 0.17; 'this?': 0.23; 'header:User-Agent:1': 0.23; 'error': 0.23; 'script': 0.25; 'idea': 0.28; 'skip:( 20': 0.30; 'lines': 0.31; 'anyone': 0.31; 'class': 0.32; 'skip:_ 10': 0.34; 'version': 0.36; 'machine.': 0.36; 'should': 0.36; 'error.': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'first': 0.61; 'pardon': 0.84 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap8EAIhDVlOGuA9G/2dsb2JhbABZhzu9doQ9g0NVKgwCBRYLAgsDAgECAUsNCAKIPZl1jx+dDYYUF4EpkCOBSQEDmHCGQowQgzM Date: Tue, 22 Apr 2014 12:29:56 +0200 From: Antoon Pardon User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Icedove/24.4.0 MIME-Version: 1.0 To: Pyton List Subject: Strange syntax error, occurs only when script is executed directly Content-Type: text/plain; charset=UTF-8 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 54 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1398162667 news.xs4all.nl 2931 [2001:888:2000:d::a6]:53789 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70497 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 Does anyone have an idea where I should look to fix this? -- Antoon Pardon