473,543 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1064
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******@signa lsguru.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
1808
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. The Python interpreter tells me instead: >>> quit 'Use Ctrl-Z plus Return to exit.' Nah, 'Ctrl-Z' is now undo :-)
0
1729
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 control. The operation takes place entirely within this single control. There is no need to provide for interaction with other controls, forms,...
48
3038
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
1848
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
4073
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 have missed it). I was wondering wether it was just a 'common' behaviour of most systems, and wether the hit of the ENTER key was mandatory. ...
31
2592
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
1603
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 frustrating time with http connections in ..Net at the moment. Basically I am working on a project in which many subsystems use http to communicate with...
4
2089
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 until the "RunMe called" was displayed! why? is the subthread active though the main thread has exited? how to explain this problem? Thank you...
285
8655
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/ specs gcc version 2.95.3 20010315 (release)
0
7355
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7697
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5285
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4899
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3394
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3394
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1830
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
648
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.