Is there a way to add text to an arbitrary place in a text file?

<pseudocode>
NewAddition="this important directive. "

Open config.config
Add new line above "# this marker text in config.config"
Insert $NewAddition in blank line created above.
Save config.config
Close config.config
<\pseudocode>

I am automating adding servers to nagios monitoring. I already have the part
that creates the new server.cfg file. This was a fairly simple bash script.
I am planning to write it in python instead, so i can let the administrator
choose the services to enable in a series of if statements, rather than
having to hand-edit the resultant file.

I need my script to add this filename to the main nagios.cfg list of read
files, but it isn't going to work to do it as a straightforward append...
Unless I can append it to a serverlist file and insert that file into
nagios.cfg at the proper position...
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to