<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
vishakha vaibhav wrote:
<blockquote cite="mid:769712.9895.qm@web53703.mail.re2.yahoo.com"
type="cite">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td
style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;"
valign="top">
<div>Hi,</div>
<div>I am very new to python. I have my cgi script written in
Python. My CGI script should call a C program and collect the value
returned by this program and pass it to the browser.</div>
<div> </div>
<div>Can anyone help me out in this. How can I execute the c
program and collect the return value.</div>
<div> </div>
<div>I tried,</div>
<div>import os</div>
<div>a=os.system("my-app")//my-app is the C program executable</div>
<div>print a</div>
<div> </div>
<div>But the variable <strong>a</strong> prints 0
everytime. It should return a non-zero value as per my C program. Is
there any method to do what I need.</div>
<div> </div>
<div>Regards,</div>
<div>vish</div>
</td>
</tr>
</tbody>
</table>
<br>
<pre wrap="">
<hr size="4" width="90%">
--
<a class="moz-txt-link-freetext" href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a>
</pre>
</blockquote>
<tt>Executing from os.system returns the return code from the
application. Take a look at the subprocess module
(<a class="moz-txt-link-freetext" href="http://docs.python.org/library/subprocess.html#module-subprocess">http://docs.python.org/library/subprocess.html#module-subprocess</a>), as
recommended by the os docs when you need to deal with capturing output
from stdout.</tt><br>
</body>
</html>