I am starting work on a script that will parse a .yaml file and prep that for entry into two files. The two files will be BIND zone files.

the yaml data will look something like this:

entries:


-hostname1 192.168.100.11
-hostname2 192.168.100.12

This will need to be manipulated and entered into two zone files.

This is an example of what the data will need to be formatted like:

File one:

hostname1 A 192.168.100.11

( 'A' is a constant )

File two:

11 IN PTR 192.168.100.11.

( IN PTR are constants )

The areas where i am having the most difficulty are How can i use python to do sed

This would work for file two first field "11"

ifconfig $1 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}' | sed /127.0.0.1/d | cut -d "." -f4

maybe I should just use the

from subprocess import call
call(["ifconfig $1 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}' | sed /127.0.0.1/d | cut -d "." -f4"])

Does this seem like the best option?

Also can someone show me an exmaple of how to print to the end of a file? I am assuming open with the append option.

open('file', "a") as FILE

I am unclear on how best to open the .yaml file grep it and then translate to print to the next file.

Thanks