[Tutor] updating Unix config file

Alan Gauld alan.gauld at btinternet.com
Tue Oct 20 09:29:59 CEST 2009


"Matt Herzog" <msh at blisses.org> wrote

> Anyway, I'd like a hint as to how I could convert this:
> 
> ifcfg_lines = os.popen("/sbin/ifconfig fxp0").readlines()
> x = string.split(ifcfg_lines[3])[1]
> 
> to the subprocess module. The os module is going away, right?

The os module is not going away although the popen 
function might some day.

However subprocess is currently the recommended way 
to do subprocess control and is more powerful and flexible 
than popen.

Did you see the subprocess documentation page that 
shows how to do the equivalent of popen etc? 
Look down to section 18.1.3.5

http://docs.python.org/library/subprocess.html#module-subprocess

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/





More information about the Tutor mailing list