Path: csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed0.kamp.net!newsfeed.kamp.net!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.81.MISMATCH!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'syntax': 0.04; 'executes': 0.09; 'parsing': 0.09; 'pgp': 0.09; 'skip:/ 10': 0.09; 'works.': 0.09; 'wrapper': 0.09; 'incorrect': 0.16; 'sees': 0.16; 'simplified': 0.16; 'sudo': 0.16; 'language': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'trying': 0.19; 'command': 0.22; 'example': 0.22; 'shell': 0.22; 'header:User-Agent:1': 0.23; 'errors.': 0.24; 'instance,': 0.24; 'passes': 0.24; 'second': 0.26; 'header:In- Reply-To:1': 0.27; 'to:2**1': 0.27; 'am,': 0.29; 'tim': 0.29; 'to:no real name:2**1': 0.29; 'quotes': 0.31; 'handled': 0.32; 'case,': 0.35; 'should': 0.36; 'machines': 0.38; 'nov': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'introduced': 0.61; 'first': 0.61; 'charset:windows-1252': 0.65; '26,': 0.68; '2014,': 0.84; 'recover': 0.91 Date: Wed, 26 Nov 2014 09:02:22 -0600 From: Tim Daneliuk User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 Newsgroups: comp.lang.python To: random832@fastmail.us, python-list@python.org Subject: Re: Quotation Ugliness References: <54756D5F.4040806@tundraware.com> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (ozzie.tundraware.com [75.145.138.73]); Wed, 26 Nov 2014 09:02:22 -0600 (CST) X-TundraWare-MailScanner-Information: Please contact the ISP for more information X-TundraWare-MailScanner-ID: sAQF2MNl037286 X-TundraWare-MailScanner: Found to be clean X-TundraWare-MailScanner-From: tundra@tundraware.com X-Spam-Status: No X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1417014174 news.xs4all.nl 2973 [2001:888:2000:d::a6]:58595 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81575 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/