Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60479
| References | <989ee1b9-141a-4cb3-a9a2-f1527c0d0db3@googlegroups.com> <ebf6c8a7-3f97-427e-b597-6a0515d1d4d8@googlegroups.com> <155f2618-7e2a-4979-9e1e-a046d9ee362b@googlegroups.com> |
|---|---|
| Date | 2013-11-26 13:41 +1100 |
| Subject | Re: Excute script only from another file |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3214.1385433670.18130.python-list@python.org> (permalink) |
On Tue, Nov 26, 2013 at 1:28 PM, Rick Johnson
<rantingrickjohnson@gmail.com> wrote:
> The only sure fire method to prevent a file containing
> Python code from executing on a machine with Python
> installed is to use an extension that the system will not
> associate with Python.
>
> ScriptFolder/
> script.py
> mod_1.ignore
> mod_2.ignore
> ...
Windows:
C:\Documents and Settings\M>copy con test.ignore
print("Hello, world!")
^Z
1 file(s) copied.
C:\Documents and Settings\M>python test.ignore
Hello, world!
Linux:
gideon@gideon:~$ cat >test.ignore
print("Hello, world!")
gideon@gideon:~$ python test.ignore
Hello, world!
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?
gideon@gideon:~$ cat >test.ignore
#!/usr/bin/python
print("Hello, world!")
gideon@gideon:~$ chmod +x test.ignore
gideon@gideon:~$ ./test.ignore
Hello, world!
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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