Re: subprocess module usage

2014-09-01 Thread Akira Li
Earl Lapus writes: > Hi, > > I made simple test program using the subprocess module (see attached: > exec_cmd.py). I ran it passing variations of 'ls' command options. > > I encounter exceptions every time I use '-l' options. Example runs > where exception occurs: > # ./exec_cmd.py ls -al > # ./e

Re: subprocess module usage

2014-09-01 Thread Chris Angelico
On Mon, Sep 1, 2014 at 6:46 PM, Cameron Simpson wrote: > Not really. If the arguments are coming in from the command line, someone (a > user, even if that user is the programmer) typed them. Even if not > malicious, they can still be mistaken. Or just unfortunate. I'm guessing that what he means

Re: subprocess module usage

2014-09-01 Thread Cameron Simpson
On 01Sep2014 14:33, Earl Lapus wrote: On Mon, Sep 1, 2014 at 1:39 PM, Chris Angelico wrote: Glad it's working! But please, don't just take my word for it and make a black-box change to your code. When you invoke subprocesses, be sure you understand what's going on, and when shell=True is appro

Re: subprocess module usage

2014-08-31 Thread Earl Lapus
On Mon, Sep 1, 2014 at 1:39 PM, Chris Angelico wrote: > > Glad it's working! But please, don't just take my word for it and make > a black-box change to your code. When you invoke subprocesses, be sure > you understand what's going on, and when shell=True is appropriate and > when shell=False is a

Re: subprocess module usage

2014-08-31 Thread Earl Lapus
On Mon, Sep 1, 2014 at 11:55 AM, Chris Angelico wrote: > > But secondly, you're already splitting the argument (or rather, taking > it from your own parameters, already split), so you don't want to go > through the shell. In fact, going through the shell would only make > your life harder. Change

Re: subprocess module usage

2014-08-31 Thread Chris Angelico
On Mon, Sep 1, 2014 at 3:24 PM, Earl Lapus wrote: > On Mon, Sep 1, 2014 at 11:55 AM, Chris Angelico wrote: >> >> But secondly, you're already splitting the argument (or rather, taking >> it from your own parameters, already split), so you don't want to go >> through the shell. In fact, going thro

Re: subprocess module usage

2014-08-31 Thread Chris Angelico
On Mon, Sep 1, 2014 at 1:28 PM, Earl Lapus wrote: > So, what could be causing this behavior? Is this expected or is there > something wrong with how I'm using the subprocess module? The latter. Your problem is with your shell= option. Firstly, the parameter should be either shell=True or shell=F

subprocess module usage

2014-08-31 Thread Earl Lapus
Hi, I made simple test program using the subprocess module (see attached: exec_cmd.py). I ran it passing variations of 'ls' command options. I encounter exceptions every time I use '-l' options. Example runs where exception occurs: # ./exec_cmd.py ls -al # ./exec_cmd.py ls -l However, if I pass