Path: csiph.com!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'scripts': 0.03; '"the': 0.07; 'linux,': 0.07; 'tries': 0.07; 'bash': 0.09; 'subject:script': 0.09; 'wrapper': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'command,': 0.16; 'it."': 0.16; 'it."': 0.16; 'script,': 0.16; 'subject:python': 0.16; 'sat,': 0.16; 'skip:# 20': 0.16; 'wrote:': 0.18; 'users.': 0.18; 'trying': 0.19; 'work,': 0.20; 'seems': 0.21; 'email addr:gmail.com>': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'script.': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'script': 0.25; 'header:In- Reply-To:1': 0.27; 'installed': 0.27; 'am,': 0.29; 'unix': 0.29; "doesn't": 0.30; 'andrew': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'easier': 0.31; 'probably': 0.32; 'run': 0.32; 'url:python': 0.33; 'beginning': 0.33; 'fri,': 0.33; 'skip:# 10': 0.33; '"the': 0.34; 'subject:with': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'adjust': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'so,': 0.37; 'being': 0.38; 'work?': 0.38; 'pm,': 0.38; 'skip:. 10': 0.39; 'url:mail': 0.40; 'how': 0.40; 'skip:* 10': 0.61; 'name': 0.63; 'header:Reply-To:1': 0.67; 'nobody': 0.68; 'reply-to:no real name:2**0': 0.71; 'reply- to:addr:gmail.com': 0.80; 'wrapper,': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:reply-to:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=pgNVuUAJZE+VDCV0ed+TKUypUsmZCC+4aflBdlhqFo8=; b=V8oCM4Eyz7FO5yknLu70/0DsH9hlACQwHMRE9UfgQ7wW+5FPh6EumFymPZZv1vj/Me MmY5PP9xD0t0my3ReWZ8xA0SxyBUHVRk8pn+q1Na17mClCSJPVRcxDr4MSfKYjY5uJOY g+oLGJvXo4iJz34d1gAo6HfYWy/ylMTGS5OpPqT/JwY59ijEhyvLjbC1bmVf+Hp+5D3L XcfD3R6PRNivGvSi6FRmLcQKXZ0xn1B3cOuDwedTNv80uxwlVubJNCatm/VY097uFgts JFUDtXlkqwpCiYjRuWg1C6+aAOWGfqEaAdswv16e2QKuvq1g5159MqvqlJBGjx4hiilz 4tYA== MIME-Version: 1.0 X-Received: by 10.58.96.72 with SMTP id dq8mr10537212veb.49.1365243301582; Sat, 06 Apr 2013 03:15:01 -0700 (PDT) In-Reply-To: References: Date: Sat, 6 Apr 2013 18:15:01 +0800 Subject: Re: Run python script with ./ From: LubanWorks To: Dylan Evans Content-Type: multipart/alternative; boundary=089e013a258605db3204d9ae7a55 Cc: python-list X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: LubanWorks@gmail.com 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: 129 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1365243311 news.xs4all.nl 6879 [2001:888:2000:d::a6]:60685 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:42903 --089e013a258605db3204d9ae7a55 Content-Type: text/plain; charset=ISO-8859-1 I have test that wrapper, under Bash 4.1.2, ./myscript.py works, it doesn't work under Bash 3.2.25, seems Bash relative. http://stackoverflow.com/questions/15838183/run-python-script-with-dot-slash On Fri, Apr 5, 2013 at 11:58 PM, Dylan Evans wrote: > > > > On Sat, Apr 6, 2013 at 1:04 AM, LubanWorks wrote: >> >> >> >> My question is: >> >> Why when I use #!/home/luban/Linux/Python/2.7.3/bin/python at the >> beginning of myscript.py, *./*myscript.py can work, >> >> but if I use the wrapper #!/home/luban/bin/python in my python script, use >> *./* to run the script, it cannot not work? >> > > Your shell will be trying to run your python script. The reason being that > when you do #!/bin/sh in the wrapper the shell tries to execute $0 which in > this case is the name of your python script. > > >> >> >> I had many scripts used #!/home/luban/bin/python when I only installed >> python under #!/home/luban/ for Linux, they can run with ./, I don't want >> to change them, >> >> so, how to let ./ run the python script If I want to *KEEP* wrapper >> #!/home/luban/bin/python as the shebang line? >> >> > Probably easier to use a symlink, or just use #!python and adjust your > $PATH. > > >> >> Best Regards, >> Luban >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> >> > > > -- > "The UNIX system has a command, nice ... in order to be nice to the other > users. Nobody ever uses it." - Andrew S. Tanenbaum > > -- > http://mail.python.org/mailman/listinfo/python-list > > --089e013a258605db3204d9ae7a55 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I have test that wrapper, under Bash 4.1.2, ./myscript.py works, it d= oesn't work under Bash 3.2.25, seems Bash relative.=

http://stackoverflow.com/questions/15838183/run-pytho= n-script-with-dot-slash


On Fri, Apr 5, 2013 at 11:58 PM, Dylan E= vans <dylan@dje.me> wrote:



On Sat, Apr 6, 2013 at 1:04 AM, LubanWorks <= luban.works@gmail.com> wrote:


My question is:

Why=A0 when I use #!/home/luban/Linux/Python= /2.7.3/bin/python at the beginning of myscript.py, ./myscript.py can work,

but if I use the wrapper #!/home/luban/bin/python in my python script,= use ./=A0 to run the sc= ript, it cannot not work?

Your sh= ell will be trying to run your python script. The reason being that when yo= u do #!/bin/sh in the wrapper the shell tries to execute $0 which in this c= ase is the name of your python script.
=A0


I had many scripts use= d #!/home/luban/bin/python when I only installed python=A0 under #!/home/lu= ban/ for Linux, they can run with ./, I don't want to change them,

so, how to let ./ run the p= ython script If I want to KEEP<= /span> wrapper #!/home/luban/b= in/python as the shebang line?


Probably easier to use a symlink= , or just use #!python and adjust your $PATH.
=A0

Best Regards,
Luban
--
http://mail.python.org/mailman/listinfo/python-list




--
"The UNIX sy= stem has a command, nice ... in order to be nice to the other users. Nobody= ever uses it." - Andrew S. Tanenbaum

--
http://mail.python.org/mailman/listinfo/python-list


--089e013a258605db3204d9ae7a55--