473,405 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Parse .yaml file and enter result into two separate files

2
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

( The A is usually the same )

File two:

11 IN PTR 192.168.100.11.

( "IN PTR" will be the same among all entires to be added to the zone file)

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

This awk and sed shell script 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 is this the best way to print to the end of a file for my scenario? 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
Jun 5 '13 #1
0 1342

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Shailesh Patel | last post by:
Hi ! Does anybody knows how to parse pdf file into xml format OR into simple text format...Help me... Thanx.. Shailesh
1
by: Newsgroup - Ann | last post by:
Hi gurus, I have two files compiled together. One file has the following global definition: char s = "asdf"; Another file has the following declaration: extern char *s;
6
by: mike | last post by:
regards: what is the mechanism of "IE" and "Firefox 1.0" to parse HTML file and show the result on the screen?....@@. thank you may god be with you
2
by: Andy Kent | last post by:
How can I export a table such that data in memo columns is sent to separate files, with placeholders in the main file? Thanks, Andy
14
by: Rob Meade | last post by:
Hi all, I'm working on a project where there are just under 1300 course files, these are HTML files - my problem is that I need to do more with the content of these pages - and the thought of...
0
Meetee
by: Meetee | last post by:
Hi.. I have created an XML file which contains username and password. I want to parse this XML file so that username and password can be stored in database. I am using TinyXML and want to parse...
5
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming. FYI Although I have called...
1
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this...
6
by: =?Utf-8?B?RGF2aWRN?= | last post by:
Hello, I have an XML file generated from a third party application that I would like to parse. Ideally, I plan on having a windows service setup to scan various folders for XML files and parse the...
0
by: Rinat | last post by:
Hi I would like to parse xml file elements and check it. if i see something is missing i want to add it to the xml. i use xmlReader and xmlWriter , but the xmlWriter WriteNode write me all the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.