newbie:trying to read in stdoutput of commands under various *nixes

googleboy mynews44 at yahoo.com
Wed Jul 14 02:47:55 EDT 2004


"Delaney, Timothy C (Timothy)" <tdelaney at avaya.com> wrote in message 

<snipped some stuff>

> import os
> pin = os.popen("uname", "r")
> 
> try:
>     print pin.read()
> finally:
>     pin.close()
> 

Thanks for the response, Tim.  This got me on the right track.   What
I actually needed was to do something like

sysName = pin.read()

so that I can compare the value of sysName with the srtong "Linux\n"
or "OpenBSD\n" and choose to run the rest of my application
accordingly.  (slightly different syntax depending on which system the
thing I am writing is to run,  y'see).

Thanks for the heads up!

googleboy.



More information about the Python-list mailing list