Re: Quotation Ugliness

2014-11-26 Thread Tim Chase
On 2014-11-26 00:04, Tim Daneliuk wrote: 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. This doesn't jibe with the pairs of quotes you sent and your request for

Re: Quotation Ugliness

2014-11-26 Thread Jussi Piitulainen
Tim Chase writes: This doesn't jibe with the pairs of quotes you sent and your request for nesting. In most popular shells, the majority of your quote characters don't actually quote anything: bash$ echo // hello hello Where did the // go? [...] and has problems with things like

Re: Quotation Ugliness

2014-11-26 Thread random832
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:

Re: Quotation Ugliness

2014-11-26 Thread Chris Angelico
On Thu, Nov 27, 2014 at 12:45 AM, Jussi Piitulainen jpiit...@ling.helsinki.fi wrote: Tim Chase writes: This doesn't jibe with the pairs of quotes you sent and your request for nesting. In most popular shells, the majority of your quote characters don't actually quote anything: bash$ echo

Re: Quotation Ugliness

2014-11-26 Thread Tim Daneliuk
On 11/26/2014 06:56 AM, Tim Chase wrote: On 2014-11-26 00:04, Tim Daneliuk wrote: 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. This doesn't jibe with the pairs of quotes

Re: Quotation Ugliness

2014-11-26 Thread Tim Daneliuk
On 11/26/2014 01:10 AM, Chris Angelico wrote: Why not set up sudo to not require a password Because I do not control the machines to which this program is talking and the security policy in question requires passwords.

Re: Quotation Ugliness

2014-11-26 Thread Tim Daneliuk
On 11/26/2014 08:12 AM, random...@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

Re: Quotation Ugliness

2014-11-26 Thread Tim Chase
On 2014-11-26 15:45, Jussi Piitulainen wrote: Tim Chase writes: bash$ echo // hello hello Where did the // go? The bad-copy-and-paste gremlins ate them :-o Good catch. :) -tkc -- https://mail.python.org/mailman/listinfo/python-list

Re: Quotation Ugliness

2014-11-26 Thread Chris Angelico
On Thu, Nov 27, 2014 at 1:58 AM, Tim Daneliuk tun...@tundraware.com wrote: The specific program in question I am modifying is one that takes a shell command and executes it remotely on many machines. The problem I am trying to solve is to determine whether the user needs to provide a sudo

Re: Quotation Ugliness

2014-11-26 Thread Chris Angelico
On Thu, Nov 27, 2014 at 1:26 AM, Tim Chase python.l...@tim.thechases.com wrote: On 2014-11-26 15:45, Jussi Piitulainen wrote: Tim Chase writes: bash$ echo // hello hello Where did the // go? The bad-copy-and-paste gremlins ate them :-o Good catch. :) I was searching the ol'

Re: Quotation Ugliness

2014-11-26 Thread Chris Angelico
On Thu, Nov 27, 2014 at 2:07 AM, Chris Angelico ros...@gmail.com wrote: I was searching the ol' memory banks, trying to figure out if there was some way to tell the internal 'echo' command to use slash instead of dash (maybe for DOS/Windows people??), in which case that would be parsed as echo

Re: Quotation Ugliness

2014-11-26 Thread random832
On Wed, Nov 26, 2014, at 10:02, Tim Daneliuk wrote: someprog.py uname sudo cat /etc/sudoers vs. someprog.py 'uname echo sudo cat /etc/suoders' I think it would be better to provide a general way for the user to provide an input script as an option, rather than to specifically

Re: Quotation Ugliness

2014-11-26 Thread Tim Daneliuk
On 11/26/2014 09:09 AM, Chris Angelico wrote: On Thu, Nov 27, 2014 at 2:07 AM, Chris Angelico ros...@gmail.com wrote: I was searching the ol' memory banks, trying to figure out if there was some way to tell the internal 'echo' command to use slash instead of dash (maybe for DOS/Windows

Re: Quotation Ugliness

2014-11-26 Thread Chris Angelico
On Thu, Nov 27, 2014 at 2:36 AM, Tim Daneliuk tun...@tundraware.com wrote: The more I think about this, the more I think I am just going to look for the string 'sudo' anywhere in the argument. This merely will force the user to enter their sudo password if detected. If it turns out to be a

Re: Quotation Ugliness

2014-11-26 Thread random832
On Wed, Nov 26, 2014, at 10:36, Tim Daneliuk wrote: The more I think about this, the more I think I am just going to look for the string 'sudo' anywhere in the argument. This merely will force the user to enter their sudo password if detected. If it turns out to be a false positive, no

Re: Quotation Ugliness

2014-11-26 Thread Tim Daneliuk
On 11/26/2014 09:48 AM, Chris Angelico wrote: On Thu, Nov 27, 2014 at 2:36 AM, Tim Daneliuk tun...@tundraware.com wrote: The more I think about this, the more I think I am just going to look for the string 'sudo' anywhere in the argument. This merely will force the user to enter their sudo

Re: Quotation Ugliness

2014-11-26 Thread random832
On Wed, Nov 26, 2014, at 10:55, Tim Daneliuk wrote: Nope. Password only exist in memory locally. How does it send it to the remote sudo? -- https://mail.python.org/mailman/listinfo/python-list

Re: Quotation Ugliness

2014-11-26 Thread Tim Daneliuk
On 11/26/2014 10:00 AM, random...@fastmail.us wrote: On Wed, Nov 26, 2014, at 10:55, Tim Daneliuk wrote: Nope. Password only exist in memory locally. How does it send it to the remote sudo? Over paramiko transport (ssh) and then only if it sees a custom string coming back from sudo asking

Re: Quotation Ugliness

2014-11-26 Thread Chris Angelico
On Thu, Nov 27, 2014 at 3:02 AM, Tim Daneliuk tun...@tundraware.com wrote: On 11/26/2014 10:00 AM, random...@fastmail.us wrote: On Wed, Nov 26, 2014, at 10:55, Tim Daneliuk wrote: Nope. Password only exist in memory locally. How does it send it to the remote sudo? Over paramiko

Re: Quotation Ugliness

2014-11-26 Thread random832
On Wed, Nov 26, 2014, at 11:02, Tim Daneliuk wrote: On 11/26/2014 10:00 AM, random...@fastmail.us wrote: On Wed, Nov 26, 2014, at 10:55, Tim Daneliuk wrote: Nope. Password only exist in memory locally. How does it send it to the remote sudo? Over paramiko transport (ssh) and then

Re: Quotation Ugliness

2014-11-26 Thread alister
On Wed, 26 Nov 2014 10:02:57 -0600, Tim Daneliuk wrote: On 11/26/2014 10:00 AM, random...@fastmail.us wrote: On Wed, Nov 26, 2014, at 10:55, Tim Daneliuk wrote: Nope. Password only exist in memory locally. How does it send it to the remote sudo? Over paramiko transport (ssh) and then

Re: Quotation Ugliness

2014-11-26 Thread Tim Daneliuk
On 11/26/2014 10:16 AM, random...@fastmail.us wrote: On Wed, Nov 26, 2014, at 11:02, Tim Daneliuk wrote: On 11/26/2014 10:00 AM, random...@fastmail.us wrote: On Wed, Nov 26, 2014, at 10:55, Tim Daneliuk wrote: Nope. Password only exist in memory locally. How does it send it to the remote

Re: Quotation Ugliness

2014-11-26 Thread Tim Daneliuk
On 11/26/2014 10:45 AM, alister wrote: On Wed, 26 Nov 2014 10:02:57 -0600, Tim Daneliuk wrote: On 11/26/2014 10:00 AM, random...@fastmail.us wrote: On Wed, Nov 26, 2014, at 10:55, Tim Daneliuk wrote: Nope. Password only exist in memory locally. How does it send it to the remote sudo?

Re: Quotation Ugliness

2014-11-26 Thread Tim Chase
On 2014-11-26 08:58, Tim Daneliuk wrote: On 11/26/2014 06:56 AM, Tim Chase wrote: On 2014-11-26 00:04, Tim Daneliuk wrote: 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

Re: Quotation Ugliness

2014-11-26 Thread Ben Finney
Tim Daneliuk tun...@tundraware.com writes: The problem I am trying to solve is to determine whether the user needs to provide a sudo password or not. Again, the ‘sudo’ program itself will figure this out and ask for a password if it needs one. Examining the command line isn't enough. Even if

Quotation Ugliness

2014-11-25 Thread Tim Daneliuk
A problem for your consideration: We are given a tuple of delimiter string pairs to quote or comment text, possibly over multiple lines. Something like this: delims = (('', ''), (', '), ('#', '\n'), (\*, *\), ('\\', '\n') ...) These may be nested. Here's the problem: Determine is the

Re: Quotation Ugliness

2014-11-25 Thread Tim Chase
On 2014-11-25 18:18, Tim Daneliuk wrote: A problem for your consideration: We are given a tuple of delimiter string pairs to quote or comment text, possibly over multiple lines. Something like this: delims = (('', ''), (', '), ('#', '\n'), (\*, *\), ('\\', '\n') ...) These may

Re: Quotation Ugliness

2014-11-25 Thread Chris Angelico
On Wed, Nov 26, 2014 at 11:18 AM, Tim Daneliuk tun...@tundraware.com wrote: A problem for your consideration: We are given a tuple of delimiter string pairs to quote or comment text, possibly over multiple lines. Something like this: delims = (('', ''), (', '), ('#', '\n'), (\*, *\),

Re: Quotation Ugliness

2014-11-25 Thread Tim Daneliuk
On 11/25/2014 06:44 PM, Chris Angelico wrote: You may have issues with your definition of nesting, though. For instance, what's it mean if you have double-quotes, then a hash? It means that the hash is quoted as part of the literal string. then the only nesting you need worry about is /* and

Re: Quotation Ugliness

2014-11-25 Thread Tim Daneliuk
On 11/25/2014 06:40 PM, Tim Chase wrote: On 2014-11-25 18:18, Tim Daneliuk wrote: A problem for your consideration: We are given a tuple of delimiter string pairs to quote or comment text, possibly over multiple lines. Something like this: delims = (('', ''), (', '), ('#', '\n'), (\*,

Re: Quotation Ugliness

2014-11-25 Thread Chris Angelico
On Wed, Nov 26, 2014 at 12:18 PM, Tim Daneliuk tun...@tundraware.com wrote: And what should happen with mismatched quotes? do(th/*is, and, th*/at) Match pairs as usual, and let the remaining unterminated quote run on. Wait, what? Where's an unterminated quote? I can imagine two ways of

Re: Quotation Ugliness

2014-11-25 Thread Tim Chase
On 2014-11-25 19:20, Tim Daneliuk wrote: hen you find any opener, you seek its corresponding closer, and then special-case /* to count any additional /* and look for a */ for each one */ . That's more or less where I was headed. I just wanted something less brute force :) This seems to

Re: Quotation Ugliness

2014-11-25 Thread Ben Finney
Tim Daneliuk tun...@tundraware.com writes: Here's the problem: Determine is the string S appears *outside* or *inside* any such quotation. This is a problem for parsing text. There is no general, simple solution. If someone tries to convince you they have one, be highly suspicious: it will

Re: Quotation Ugliness

2014-11-25 Thread Tim Daneliuk
On 11/25/2014 07:32 PM, Chris Angelico wrote: On Wed, Nov 26, 2014 at 12:18 PM, Tim Daneliuk tun...@tundraware.com wrote: And what should happen with mismatched quotes? do(th/*is, and, th*/at) Match pairs as usual, and let the remaining unterminated quote run on. Wait, what? Where's

Re: Quotation Ugliness

2014-11-25 Thread Tim Daneliuk
On 11/25/2014 07:44 PM, Tim Chase wrote: On 2014-11-25 19:20, Tim Daneliuk wrote: hen you find any opener, you seek its corresponding closer, and then special-case /* to count any additional /* and look for a */ for each one */ . That's more or less where I was headed. I just wanted

Re: Quotation Ugliness

2014-11-25 Thread Tim Daneliuk
On 11/25/2014 07:54 PM, Ben Finney wrote: Tim Daneliuk tun...@tundraware.com writes: Here's the problem: Determine is the string S appears *outside* or *inside* any such quotation. This is a problem for parsing text. There is no general, simple solution. If someone tries to convince you

Using a password with ‘sudo’ (was: Quotation Ugliness)

2014-11-25 Thread Ben Finney
Tim Daneliuk tun...@tundraware.com writes: 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: […] In the first instance, I need the sudo passoword, in the second I don't. I don't understand what “need a

Re: Quotation Ugliness

2014-11-25 Thread Chris Angelico
On Wed, Nov 26, 2014 at 5:04 PM, Tim Daneliuk tun...@tundraware.com wrote: 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