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


Groups > comp.lang.python > #60529

Re: Excute script only from another file

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
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:file': 0.07; 'defines': 0.09; 'executable': 0.09; 'prevents': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:script': 0.09; 'windows': 0.15; '.py': 0.16; '>to': 0.16; 'invoked.': 0.16; 'line),': 0.16; 'mean,': 0.16; 'message- id:@4ax.com': 0.16; 'names?': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'extensions': 0.16; 'variable': 0.18; 'first.': 0.19; 'skip:p 40': 0.19; '(the': 0.22; 'command': 0.22; 'entries': 0.24; 'unix/linux': 0.24; 'url:home': 0.24; '(or': 0.24; 'environment': 0.24; 'script': 0.25; 'extension': 0.26; 'defined': 0.27; 'header:X-Complaints-To:1': 0.27; 'idea': 0.28; 'chris': 0.29; 'label': 0.30; 'relies': 0.31; 'allows': 0.31; 'file': 0.32; 'skip:c 30': 0.32; 'another': 0.32; 'open': 0.33; "i'd": 0.34; 'subject:from': 0.34; 'but': 0.35; 'add': 0.35; 'charset:us-ascii': 0.36; 'behind': 0.37; 'nov': 0.38; 'skip:. 20': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'skip:. 10': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'manually': 0.60; 'identify': 0.61; 'first': 0.61; 'linked': 0.65; 'sample': 0.67; 'absolutely': 0.87; 'received:108': 0.93; '2013': 0.98
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Excute script only from another file
Date Tue, 26 Nov 2013 12:25:58 -0500
Organization IISS Elusive Unicorn
References <989ee1b9-141a-4cb3-a9a2-f1527c0d0db3@googlegroups.com> <ebf6c8a7-3f97-427e-b597-6a0515d1d4d8@googlegroups.com> <155f2618-7e2a-4979-9e1e-a046d9ee362b@googlegroups.com> <CAPTjJmp6NbLBix_2aDBCW-o+M6d87nrM9HbEh0n-kXUOekY4Ug@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-108-73-119-194.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 6.00/32.1186
X-No-Archive YES
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.3251.1385486755.18130.python-list@python.org> (permalink)
Lines 70
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1385486755 news.xs4all.nl 15971 [2001:888:2000:d::a6]:43845
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:60529

Show key headers only | View raw


On Tue, 26 Nov 2013 13:41:07 +1100, Chris Angelico <rosuav@gmail.com>
declaimed the following:

>
>Totally sure-fire. Absolutely prevents any execution until it's
>renamed. By the way, what does "associate" mean, and what does it have
>to do with file names?
>
	Windows-speak...

	Where UNIX/Linux relies upon the first line of a script to identify
what executable is used to process it (the #! line), Windows uses a linked
pair of registry entries


C:\Users\Wulfraed\Documents>assoc .py
.py=Python.File

C:\Users\Wulfraed\Documents>ftype python.file
python.file="C:\PYTHON~2\Python27\python.exe" "%1" %*

C:\Users\Wulfraed\Documents>


	"ftype" takes a type label and defines the command line used to execute
that file type (or otherwise open the file... ).

	"assoc" takes a file extension and "associates" it with the type label
-- allows multiple extensions to be linked to one command line

.py=Python.File
.pyc=Python.CompiledFile
.pyo=Python.CompiledFile
.pys=pysFile
.pyw=Python.NoConFile


Python.CompiledFile="C:\PYTHON~2\Python27\python.exe" "%1" %*
Python.File="C:\PYTHON~2\Python27\python.exe" "%1" %*
Python.NoConFile="C:\PYTHON~2\Python27\pythonw.exe" "%1" %*

(No idea where .pys came from -- it has no defined executor)

	These are how one can do things like

C:\Users\Wulfraed\Documents>scite t.py

C:\Users\Wulfraed\Documents>python t.py
Goodbye

C:\Users\Wulfraed\Documents>t.py
Goodbye

C:\Users\Wulfraed\Documents>t
Goodbye

	There's another environment variable that defines what order to search
extensions when not provided (as in the last sample above), as one may have
a t.py, t.bat, t.doc, etc.

PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.py;.pyw

Hmmm, think I need to edit that... shove the .py* behind .bat -- I don't
use the others so why have the system try to find them first. I'd add
powershell but its designed for security and pretty much needs to be
manually invoked.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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


Thread

Excute script only from another file Himanshu Garg <hgarg.india@gmail.com> - 2013-11-24 17:55 -0800
  Re: Excute script only from another file Chris Angelico <rosuav@gmail.com> - 2013-11-25 14:15 +1100
  Re: Excute script only from another file Dave Angel <davea@davea.name> - 2013-11-24 22:20 -0500
    Re: Excute script only from another file Larry Hudson <orgnut@yahoo.com> - 2013-11-26 00:10 -0800
  Re: Excute script only from another file Michael Torrie <torriem@gmail.com> - 2013-11-24 19:58 -0700
  Re: Excute script only from another file Peter Otten <__peter__@web.de> - 2013-11-25 09:12 +0100
  Re: Excute script only from another file Himanshu Garg <hgarg.india@gmail.com> - 2013-11-25 02:52 -0800
    Re: Excute script only from another file Dave Angel <davea@davea.name> - 2013-11-25 07:16 -0500
    Re: Excute script only from another file Rick Johnson <rantingrickjohnson@gmail.com> - 2013-11-25 18:28 -0800
      Re: Excute script only from another file Chris Angelico <rosuav@gmail.com> - 2013-11-26 13:41 +1100
        Re: Excute script only from another file Rick Johnson <rantingrickjohnson@gmail.com> - 2013-11-25 19:45 -0800
      Re: Excute script only from another file Steven D'Aprano <steve@pearwood.info> - 2013-11-26 03:09 +0000
      Re: Excute script only from another file Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-11-26 12:25 -0500
      Re: Excute script only from another file Chris Angelico <rosuav@gmail.com> - 2013-11-27 10:09 +1100
        Re: Excute script only from another file Rick Johnson <rantingrickjohnson@gmail.com> - 2013-11-26 17:56 -0800
          Re: Excute script only from another file Chris Angelico <rosuav@gmail.com> - 2013-11-27 13:39 +1100

csiph-web