newbie:trying to read in stdoutput of commands under various*nixes
Delaney, Timothy C (Timothy)
tdelaney at avaya.com
Wed Jul 14 20:30:56 EDT 2004
googleboy wrote:
> Thanks for the response, Tim. This got me on the right track.
That's the aim. You were just missing a critical piece, and being
confused by the fact that it was printing "Linux" as you expected it to
...
> 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).
You may want to strip() the data returned so you can compare directly
against "Linux" and "OpenBSD" (rather than having to include a newline
in the comparison string).
Tim Delaney
More information about the Python-list
mailing list