Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:error': 0.03; 'syntax': 0.04; 'received:134': 0.05; 'processing.': 0.07; '22,': 0.09; 'bash': 0.09; 'counting': 0.09; 'subject:script': 0.09; 'works.': 0.09; 'python': 0.11; 'subject:when': 0.16; 'symlink': 0.16; 'unexpected': 0.16; 'skip:# 20': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'thanks.': 0.20; 'code,': 0.22; 'header:User- Agent:1': 0.23; 'error': 0.23; 'script.': 0.24; 'looks': 0.24; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'run': 0.32; '(including': 0.33; "i'd": 0.34; 'problem.': 0.35; 'something': 0.35; 'error.': 0.37; 'wrong': 0.37; 'being': 0.38; 'subject:]': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'itself': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'first': 0.61; 'such': 0.63; 'maximum': 0.63; 'yes': 0.68; 'pardon': 0.84 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqAEAItdVlOGuA9G/2dsb2JhbABZhzvBB4EtgxkBAQUjVRELGAICBRYLAgIJAwIBAgFFEwYCAog9qR2dFIYUF4EpjTQWglmBSQEDmHCGQowQgzM Date: Tue, 22 Apr 2014 14:21:34 +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: python-list@python.org Subject: Re: Strange syntax error, occurs only when script is executed directly [solved] References: <535644A4.6060901@rece.vub.ac.be> In-Reply-To: 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1398169297 news.xs4all.nl 2968 [2001:888:2000:d::a6]:45848 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70503 On 22-04-14 14:09, Chris Angelico wrote: > On Tue, Apr 22, 2014 at 8:29 PM, Antoon Pardon > wrote: >> 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):' > That looks like bash trying to run Python code, so I'd look at > something being wrong with the shebang processing. What's > /opt/local/bin/python? Is it a symlink to something else? Some systems > won't allow any such dereferencing, others (including modern Linux) > allow a maximum of ten or thereabouts, counting one for every symlink > or shebang'd script. If /opt/local/bin/python is a bouncer script that > itself has a shebang, that might be your problem. > > ChrisA Yes that was it. I changed the first line of my script to: #!/opt/local/bin/python2.7 and it now works. Thanks. -- Antoon Pardon