Beginner asks question about Python on Linux
Mats Kronbladh
mats.kronbladh at entra.se
Fri Oct 8 06:43:27 EDT 1999
stephen.allison at cenes.co.uk wrote:
>
> [...] What I want to know is
> if there is a way of getting the output of the grep straight into
> Python, so I won't have to use a temporary file. I have since learned
> about killing all processes of a given name, so it's a bit academic,
> but I was wondering if anyone could tell me if it's possible to do
> this, using either Python cleverness or some shell commands I'm not
> aware of.
I currently have host booted for NT, but I think this will work under
posix as well:
C:\WINNT\SYSTEM32>d:\dev\python\python
Python 1.5 (#0, Dec 30 1997, 23:24:20) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import os
>>> f = os.popen("dir c:\\")
>>> f.readline()
' Volume in drive C has no label.\012'
>>> f.readline()
' Volume Serial Number is 07CE-0C12\012'
>>> f.readline()
'\012'
>>> f.close()
Try this, it might be just what your looking for...?
Regards,
/mk
______________________________________________________________________
Mats Kronbladh Entra Internet Solutions AB
mats.kronbladh at entra.se http://www.entra.se/
Cellular: +46-70-9790576
More information about the Python-list
mailing list