subprocess.popen function with quotes

skunkwerk skunkwerk at
Wed Mar 26 04:31:19 CET 2008

   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$/

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