On 2/26/07, <b class="gmail_sendername">Nagendra Singh</b> <<a href="mailto:singh01@gmail.com">singh01@gmail.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thanks a lot for all the suggestions. I used the function subprocess.call ( 'c:\abc.exe c:\data\file1'), but as before the command window opens and closes very fast a value of 1 is displayed. How do I see the results?? I am sorry if I sound dumb.
<br><span class="sg"><br>Singh</span><div><span class="e" id="q_110fef4695f783d9_2"><br><br><div><span class="gmail_quote">On 2/23/07, <b class="gmail_sendername">Alan Gauld</b> <<a href="mailto:alan.gauld@btinternet.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
alan.gauld@btinternet.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>"Rikard Bosnjakovic" <<a href="mailto:rikard.bosnjakovic@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">rikard.bosnjakovic@gmail.com</a>> wrote<br><br>>> How can I get python to display
<br>>> the results in the interactive window or what is the right way to
<br>>> do this.<br>><br>> Use os.popen:<br><br>As Rikard, Richard and Hugo have pointed out there are<br>numerous ways to do this in Python.<br><br>The officially sanctioned way nowadays is to use the subprocess
<br>module. It supercedes all tthe previous methods being both more<br>powerful, more flexible and fairly easy to use.<br><br>All the techniques are discussed in my Using the OS topic in<br>my tutorial.<br><br>HTH,<br><br>
--<br>Alan Gauld<br>Author of the Learn to Program web site<br><a href="http://www.freenetpages.co.uk/hp/alan.gauld" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.freenetpages.co.uk/hp/alan.gauld
</a><br><br><br>_______________________________________________
<br>Tutor maillist - <a href="mailto:Tutor@python.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://mail.python.org/mailman/listinfo/tutor</a><br></blockquote></div><br>
</span></div><br>_______________________________________________<br>Tutor maillist - <a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:Tutor@python.org">Tutor@python.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">
http://mail.python.org/mailman/listinfo/tutor</a><br><br></blockquote></div><br>I am not a big user of python, hence the username, however I used the os.popen command as suggested by Rikard<br>
<br>
In the shell:<br>
<br>
data = os.popen('ls')<br>
type(data)<br>
<type 'file'><br>
Then a loop over the data object<br>
for f in data:<br>
print f<br>
<br>
seemed to do the job.<br>
<br>
I did notice that I could not capture the information to a var using the subprocess call - I HAVE NOT READ THE DOCs (yet) - a quick look suggested that this *should* work<br>
<br>
The call I made using subprocess<br>
from subprocess import call<br>
foo = call("ls")<br>
<PRINTS CONTENTS OF /HOME/><br>
<FOO IS == 0 ><br>
<br><br>