subprocess.popen function with quotes

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Mar 26 02:04:49 EDT 2008


En Wed, 26 Mar 2008 02:15:28 -0300, skunkwerk <skunkwerk at gmail.com>  
escribió:

> On Mar 25, 9:25 pm, "Gabriel Genellina" <gagsl-... at yahoo.com.ar>
> wrote:
>> En Wed, 26 Mar 2008 00:39:05 -0300, skunkwerk <skunkw... at gmail.com>  
>> escribió:
>>
>> >>    i'm trying to call subprocess.popen on the 'rename' function in
>> >> linux.  When I run the command from the shell, like so:
>>
>> >> rename -vn 's/\.htm$/\.html/' *.htm
>>
>> >> it works fine... however when I try to do it in python like so:
>> >> p = subprocess.Popen(["rename","-vn","'s/\.htm$/
>> >> \.html/'","*.htm"],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
>>
>> >> print p.communicate()[0]
>>
>> >> nothing gets printed out (even for p.communicate()[1])
>>
>> I'd try with:
>>
>> p = subprocess.Popen(["rename", "-vn", r"'s/\.htm$/\.html/'", "*.htm"],
>>        stdout=subprocess.PIPE, stderr=subprocess.PIPE,
>>        shell=True)
>>
>> (note that I added shell=True and I'm using a raw string to specify the  
>> reg.expr.)
>
> Thanks Gabriel,
>    I tried the new command and one with the raw string and single
> quotes, but it is still giving me the same results (no output).  any
> other suggestions?

My next try would be without the single quotes...

-- 
Gabriel Genellina




More information about the Python-list mailing list