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


Groups > comp.lang.python > #60479

Re: Excute script only from another file

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'python.': 0.02; 'subject:file': 0.07; 'prevents': 0.09; 'subject:script': 0.09; 'python': 0.11; 'copied.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'mean,': 0.16; 'names?': 0.16; 'windows:': 0.16; 'world!': 0.16; 'world!")': 0.16; 'prevent': 0.16; 'wrote:': 0.18; 'machine': 0.22; 'extension': 0.26; 'header :In-Reply-To:1': 0.27; 'installed': 0.27; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'file': 0.32; 'skip:# 10': 0.33; 'totally': 0.33; 'subject:from': 0.34; 'johnson': 0.35; 'received:google.com': 0.35; 'executing': 0.36; 'method': 0.36; 'nov': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'skip:. 10': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'fire': 0.65; '26,': 0.68; 'containing': 0.69; 'absolutely': 0.87; 'rick': 0.93; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=9dBWX11YVH0EzUKuNVJqRhJP3/2+q8O/ZxWRKyov8XM=; b=xo1nV/1SYKPDivYRXDRrLPIDFEDceBcwdfPmA8GNW78nwIEitjeY3PropSFO0nWNWP 8FYHMQEDoAgfe0DYjZFPwbhKsuvKWMtxYbvQcvywYdPvY4HRtreY2SdGUaxlTKMhBKHu SV2UL2GqQ2RdLZGfOKyxpCHp8c2B1I33OVFs/+APt8MkRh/MG6JjDyhnaXFec9XrGPs7 LDOTv15AQ0u1OJ4/XSHO1uVe9i0IRCErXZ5r6jYr7S5SMQvjWlotcWs2bXKTbcYKrj23 fTd16oiplxU6xT7Nk5Mhwk5p3Du1XQOk/v9Cl2tzJWK2XC/KWNRvQ1rnM+xj/ZJXRPN8 aXfQ==
MIME-Version 1.0
X-Received by 10.69.31.1 with SMTP id ki1mr11028612pbd.124.1385433667253; Mon, 25 Nov 2013 18:41:07 -0800 (PST)
In-Reply-To <155f2618-7e2a-4979-9e1e-a046d9ee362b@googlegroups.com>
References <989ee1b9-141a-4cb3-a9a2-f1527c0d0db3@googlegroups.com> <ebf6c8a7-3f97-427e-b597-6a0515d1d4d8@googlegroups.com> <155f2618-7e2a-4979-9e1e-a046d9ee362b@googlegroups.com>
Date Tue, 26 Nov 2013 13:41:07 +1100
Subject Re: Excute script only from another file
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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.3214.1385433670.18130.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1385433670 news.xs4all.nl 15873 [2001:888:2000:d::a6]:42798
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:60479

Show key headers only | View raw


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 | 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