Newbie: freebsd admin scripting
willmaier at ml1.net
Thu Jul 19 02:48:33 CEST 2007
On Wed, Jul 18, 2007 at 04:31:35PM -0700, Evan Klitzke wrote:
> > I found a built in mod for parseconfig but it deal with .ini
> > file styles (windows) that include a [section] header as well as
> > uses someiteam=somevalue format. I believe it requires the
> > header though.
> I think you're referring to ConfigParser. This is the standard way
> to do config files in Python, and it is very simple to use and
> work with, so I would recommend using it.
rc.conf is a shell script on BSD systems. The OP will need to write
his own parser to read it. Take a look at the wiki's list of
parsers, specifically shlex. I haven't used it to parse things
like rc.conf, but I imagine it could be useful.
> > Books or howtos regarding Unix admin scripting(python) would be
> > great. Is this type of scripting mainly executing a Unix
> > command and capturing and parsing its output like this:
> > x=command.getoutput("ifconfig")
> > and them parsing x for what I want or is there a name space I
> > can call to get , for example, a list of all interfaces?
Nothing in the standard library handles interface configuration,
though there may be a package somewhere to help you with that. In
general, yes, you'll be writing your own scripts wrapping around
system commands. As Evan says, be smart and keep those scripts
around. As you figure things out, generalize your scripts and create
some useful classes, etc.
[Will Maier]-----------------[willmaier at ml1.net|http://www.lfod.us/]
More information about the Python-list