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


Groups > comp.lang.python > #42903

Re: Run python script with ./

References <CALpAWgMZv=0Pvtz7sDUgMHjR94J7gOjGKGL3iYRqEyWjUXLeTA@mail.gmail.com> <CADQvV+uNvLe9g_OdgoeWYeWqtGxO9OtPDMj_q09OHnQ_6RG2ow@mail.gmail.com>
Date 2013-04-06 18:15 +0800
Subject Re: Run python script with ./
From LubanWorks <luban.works@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.196.1365243311.3114.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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 <dylan@dje.me> wrote:

>
>
>
> On Sat, Apr 6, 2013 at 1:04 AM, LubanWorks <luban.works@gmail.com> 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
>
>

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


Thread

Re: Run python script with ./ LubanWorks <luban.works@gmail.com> - 2013-04-06 18:15 +0800

csiph-web