Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Tim Daneliuk Newsgroups: comp.lang.python Subject: Re: Quotation Ugliness Date: Wed, 26 Nov 2014 09:02:22 -0600 Organization: A noiseless patient Spider Lines: 40 Message-ID: <5475EB7E.7010802@tundraware.com> References: <54756D5F.4040806@tundraware.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: mx02.eternal-september.org; posting-host="d887b3e675279b69468e57e74ea1dcb8"; logging-data="869"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+6M6ne9dJDCgtVvzpRWxqRcc0+93Vbifw=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: Cancel-Lock: sha1:I/xPkY2ByYMk1Rmv+KfpdHEYSMA= Xref: csiph.com comp.lang.python:81580 On 11/26/2014 08:12 AM, random832@fastmail.us wrote: > On Wed, Nov 26, 2014, at 01:04, Tim Daneliuk wrote: >> In this case, I am not trying to write a fullblown language or recover >> from syntax errors. Here's a usecase - I want to know whether I need >> to use a sudo password when the user passes a command on the command line >> of a program: >> >> someprog.py uname && sudo cat /etc/sudoers >> >> vs. >> >> someprog.py uname && echo "sudo cat /etc/suoders" >> >> >> In the first instance, I need the sudo passoword, in the second I don't. > > I think first you need to understand how the command line works. Much of > this parsing - including both && and quotes - is handled by the shell > before your program ever sees it. > I am not writing in shell nor am I escaping to the shell locally for execution someprog.py is a paramiko-based wrapper that executes the given command on many machines remotely. I (over) simplified the example and in my haste introduced and incorrect idea. What this should say is: someprog.py "uname && sudo cat /etc/sudoers" vs. someprog.py 'uname && echo "sudo cat /etc/suoders"' -- ---------------------------------------------------------------------------- Tim Daneliuk tundra@tundraware.com PGP Key: http://www.tundraware.com/PGP/