confusing behaviour of os.system

T

Todd

I'm trying to run the following in python.

os.system('/usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file
\"test.c\")"')

This connects to xemacs with gnuclient and runs htmlize. If I run it
from a shell, xemacs gives me an error, but it generates the html file
just fine. If I run the same statement in python, I get the exact same
behaviour, but there's no file.

I'm not sure what the issue is. I thought maybe it's putting it in
another directory or there might be some permissions problem. Any
ideas? If you want to try it, just make sure to run "M-x
gnuserve-start" first.
 
B

Ben Cartwright

Todd said:
I'm trying to run the following in python.

os.system('/usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file
\"test.c\")"')

Python is interpreting the \"s as "s before it's being passed to
os.system. Try doubling the backslashes.
/usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file> \"test.c\")"

--Ben
 
T

Todd

Ben said:
Python is interpreting the \"s as "s before it's being passed to
os.system. Try doubling the backslashes.

/usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file> \"test.c\")"

--Ben

Thanks! Yay multiple layers of string interpretation.
 
B

Ben Finney

Todd said:
Thanks! Yay multiple layers of string interpretation.

If it helps, Python has "raw string" syntax that can help alleviate this.
/usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file> \"test.c\")"
/usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file> \"test.c\")"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,292
Messages
2,571,494
Members
48,171
Latest member
EllaHolmwo

Latest Threads

Top