Re: Yet Another Command Line Parser

From: Manlio Perillo (NOmanlio_perilloSPAM_at_libero.it)
Date: 10/27/04


Date: Wed, 27 Oct 2004 08:34:16 GMT

On Tue, 26 Oct 2004 19:33:42 GMT, Andrew Dalke <adalke@mindspring.com>
wrote:

>Manlio Perillo wrote:
>> # add spaces to avoids errors like: 1 2, 3 4 -> (12, 34)
>> _options = ' '.join(sys.argv[1:])
>>
>> def call(func):
>> """
>> Call func, passing to it the arguments from the command line
>> """
>> exec('func(' + _options + ')')
>
>> The only problem is that error messages are ugly.
>
>And it's a huge security hole. What if I did
>
>
>script.py "x=6)\
>import os
>os.system('ls -l')"
>

I'm not sure (it does not works on Windows 'shell'), have you run this
code? It does not raises a SyntaxError?

>Even if not a security hole, it's tricky to handle the
>combined shell and Python escaping rules
>
> script.py x="This is a string"
>
>won't work, while
>
> script.py 'x="This is a string"'
>

Actually on Windows the right syntax is
script.py x='"This is a string"'

>should. Embedding ! and \escaped characters should be
>even more fun.
>

Thanks and regards Manlio Perillo



Relevant Pages

  • Re: wuauclt.exe problem and 0x800706BE error
    ... it restarted I had to clear 35 wuauclt.exe problem windows to continue. ... also closed all programs and my AV software before initializing the command. ... the error messages again. ...
    (microsoft.public.windowsupdate)
  • Re: Error number: 0x80070420
    ... If you get any error messages, try the same command while in Safe Mode ... Noel Paton (MS-MVP 2002-2005, Windows) ... > does anyone have any idea how to get updates running? ...
    (microsoft.public.windowsupdate)
  • Re: Error number: 0x80070420
    ... If you get any error messages, try the same command while in Safe Mode ... Noel Paton (MS-MVP 2002-2005, Windows) ... >I reinstalled Windows XP Home over my existing XP Home installation, ...
    (microsoft.public.windowsupdate)
  • Re: How do I assign Word Viewer 2003 to Quick View Shell command?
    ... It sounds like the command to open the viewer is incorrect. ... > After switching to Windows XP Home Edition, ... > produces the following error messages: ...
    (microsoft.public.office.misc)
  • RE: re-setting boot partition
    ... Description of the Windows 2000 Recovery Console ... For a Microsoft Windows XP version of this article, ... MB of hard disk space on your system partition to hold the Cmdcons folder ... Windows NTBoot Console Command Interpreter. ...
    (microsoft.public.win2000.setup_upgrade)

Loading