473,387 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

confusing behaviour of os.system

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.

Apr 7 '06 #1
3 1061
Todd wrote:
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.
print '/usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file> \"test.c\")"' /usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file> "test.c")" print '/usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file> \\"test.c\\")"'

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

--Ben

Apr 7 '06 #2

Ben Cartwright wrote:
Todd wrote:
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.
print '/usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file> \"test.c\")"' /usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file> "test.c")" print '/usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file> \\"test.c\\")"'

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

--Ben


Thanks! Yay multiple layers of string interpretation.

Apr 7 '06 #3
"Todd" <go******@signalsguru.net> writes:
Ben Cartwright wrote:
>> print '/usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file> \"test.c\")"'

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

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

--Ben


Thanks! Yay multiple layers of string interpretation.


If it helps, Python has "raw string" syntax that can help alleviate this.
print r'/usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file> \"test.c\")"' /usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file> \"test.c\")"
filename = "test.c"
cmd_template = r'/usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file> \"%s\")"'
command = cmd_template % filename
print command

/usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file> \"test.c\")"
--
\ "Everything is futile." -- Marvin of Borg |
`\ |
_o__) |
Ben Finney

Apr 7 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Kay Schluehr | last post by:
The documentation of the Python console behaviour is not correct anymore for Python 2.4.1. At least for the Win2K system I'm working on 'Ctrl-Z' does not shut down the console but 'Ctrl-D' etc. ...
0
by: Plumer | last post by:
Hello everyone, I am using MS .NET Framework 1.0 Version 1.0.3705 developing a C# client application using SQL Server on the server side. I am looking to implement drag & drop in a TreeView...
48
by: marbac | last post by:
Hi, i heard a lot about "undefined behaviour" in this and other newsgroups dealing with c/c++. Is there a list where all cases with undefined behaviour in C++ are listed? regards marbac
5
by: Mantorok Redgormor | last post by:
#define FOO(x,y) ((int)&(((x*)NULL)->y)) How is this legal? It is accessing the member of a struct whose address is "zero". Since NULL is zero.
12
by: Emmanuel Delahaye | last post by:
Hi there, It is commonly accepted that a call to the getchar() function suspends the execution of the current program. I have not found any description of this behaviour in the standard (I may...
31
by: DeltaOne | last post by:
#include<stdio.h> typedef struct test{ int i; int j; }test; main(){ test var; var.i=10; var.j=20;
0
by: Rob Levine | last post by:
(This post also available at http://roblevine.blogspot.com/2004/11/frustrating-http-connection-behaviour.html in a slightly more readable format!) Hi All, I seem to be having a bit of a...
4
by: supermonkey | last post by:
In my opinion, all subthreads will be terminated when the main thread exit ,but the following program pose a surprise to me~ After "Hello world!" was displayed on the screen, the program will wait...
285
by: Sheth Raxit | last post by:
Machine 1 : bash-3.00$ uname -a SunOS <hostname5.10 Generic_118822-30 sun4u sparc SUNW,Sun-Fire-280R bash-3.00$ gcc -v Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/2.95.3/...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.