Quotation Ugliness

Tim Daneliuk tundra at tundraware.com
Wed Nov 26 16:02:22 CET 2014


On 11/26/2014 08:12 AM, random832 at 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 at tundraware.com
PGP Key:         http://www.tundraware.com/PGP/




More information about the Python-list mailing list