On 2/26/07, Nagendra Singh <[EMAIL PROTECTED]> wrote:

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.

Singh

On 2/23/07, Alan Gauld <[EMAIL PROTECTED]> wrote:
>
>
> "Rikard Bosnjakovic" <[EMAIL PROTECTED]> wrote
>
> >> How can I get python to display
> >> the results in the interactive window or what is the right way to
> >> do this.
> >
> > Use os.popen:
>
> As Rikard, Richard and Hugo have pointed out there are
> numerous ways to do this in Python.
>
> The officially sanctioned way nowadays is to use the subprocess
> module. It supercedes all tthe previous methods being both more
> powerful, more flexible and fairly easy to use.
>
> All the techniques are discussed in my Using the OS topic in
> my tutorial.
>
> HTH,
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.freenetpages.co.uk/hp/alan.gauld
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


I am not a big user of python, hence the username, however I used the
os.popen command as suggested by Rikard

In the shell:

data = os.popen('ls')
type(data)
   <type 'file'>
Then a loop over the data object
for f in data:
   print f

seemed to do the job.

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

The call I made using subprocess
from subprocess import call
foo = call("ls")
 <PRINTS CONTENTS OF /HOME/>
 <FOO IS == 0 >
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to