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


Groups > comp.lang.python > #60529

Re: Excute script only from another file

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Excute script only from another file
Date 2013-11-26 12:25 -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>
Newsgroups comp.lang.python
Message-ID <mailman.3251.1385486755.18130.python-list@python.org> (permalink)

Show all headers | 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