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: 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 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> <155f2618-7e2a-4979-9e1e-a046d9ee362b@googlegroups.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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Tue, 26 Nov 2013 13:41:07 +1100, Chris Angelico 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/