forked from olafhartong/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsvtoxml.sh
More file actions
34 lines (29 loc) · 1.42 KB
/
csvtoxml.sh
File metadata and controls
34 lines (29 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
HOST=export_acs-feb.csv
year=`date +%Y`
month=`date +%m`
day=`date +%d`
hour=`date +%H`
min=`date +%M`
timestamp=${year}${month}${day}${hour}${min}
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" >> endpoints-$timestamp.xml
echo "<TipsContents xmlns=\"http://www.avendasys.com/tipsapiDefs/1.0\">" >> endpoints-$timestamp.xml
echo " <TipsHeader exportTime=\"Tue Oct 21 10:00:00 CET 2015\" version=\"6.5\"/>" >> endpoints-$timestamp.xml
echo " <Endpoints>" >> endpoints-$timestamp.xml
exec 3<&0
exec 0<$HOST
while read ENDPOINT
do
echo "Generating for $ENDPOINT"
MAC=$(echo "$ENDPOINT" | awk 'BEGIN {FS = ";"} {print $1}' | tr -d -)
DESC=$(echo "$ENDPOINT" | awk 'BEGIN {FS = ";"} {print $2}')
GRP=$(echo "$ENDPOINT" | awk 'BEGIN {FS = ";"} {print $4}')
echo " <Endpoint macAddress=\"$MAC\" status=\"Known\" description=\"$DESC\">" >> endpoints-$timestamp.xml
echo " <EndpointTags tagname=\"Device Type\" tagValue=\"$GRP\"/>" >> endpoints-$timestamp.xml
echo " </Endpoint>" >> endpoints-$timestamp.xml
done
echo " </Endpoints>" >> endpoints-$timestamp.xml
echo " <TagDictionaries>" >> endpoints-$timestamp.xml
echo " <TagDictionary allowMultiple="true" mandatory="false" dataType="String" attributeName="Device Type" entityName="Endpoint"/>" >> endpoints-$timestamp.xml
echo " </TagDictionaries>" >> endpoints-$timestamp.xml
echo "</TipsContents>" >> endpoints-$timestamp.xml