subprocess.popen function with quotes

skunkwerk skunkwerk at gmail.com
Tue Mar 25 23:39:05 EDT 2008


also, i've tried the Shell=True parameter for Popen, but that didn't
seem to make a difference

On Mar 25, 8:31 pm, skunkwerk <skunkw... at gmail.com> wrote:
> Hi,
>    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 think the problem is the quoted string the rename command wants -
> when I put it in triple quotes like """s/\.htm$/\.html/""" I get some
> output, but not the correct output.  I've also tried escaping the
> single quotes with \' and putting it in regular double quotes but that
> didn't work either.
>
> i'd appreciate any help




More information about the Python-list mailing list