Insert values into template

I have 2 files.

Template file:
[TYPE]SELECT[/TYPE]
[BEGIN][/BEGIN]
[END][/END]
[SECTION]NAME = ""[/SECTION]
[VALUE]DEATILS[/VALUE]
Input file:
SERVER1 06/05/2016 10:00:00 06/05/2016 05:08:59
SERVER2 06/04/2016 09:50:00 06/05/2016 01:03:59
SERVER3 06/06/2016 11:26:00 06/06/2016 10:31:55

I want to generate the output file that look like this:

[TYPE]SELECT[/TYPE]
[BEGIN]06/05/2016 10:00:00[/BEGIN]
[END]06/05/2016 05:08:59[/END]
[SECTION]NAME = "SERVER1"[/SECTION]
[VALUE]DEATILS[/VALUE]
[TYPE]SELECT[/TYPE]
[BEGIN]06/04/2016 09:50:00[/BEGIN]
[END]06/05/2016 01:03:59[/END]
[SECTION]NAME = "SERVER2"[/SECTION]
[VALUE]DEATILS[/VALUE]
[TYPE]SELECT[/TYPE]
[BEGIN]06/06/2016 11:26:00[/BEGIN]
[END]06/06/2016 10:31:55[/END]
[SECTION]NAME = "SERVER3"[/SECTION]
[VALUE]DEATILS[/VALUE]

My code is working fine but i dont want to hardcode the template contents inside the script. I need to read the template and then generate the output file.Any help would be greatly appreciated.

for Line in `cat ${inputfile}`
do
ServerName=`echo $Line|awk '{print $1}`
STARTDATETIME=`echo $Line|awk '{print $2,$3}`
ENDDATETIME=`echo $Line|awk '{print $4,$5}`
echo "[TYPE]SELECT[/TYPE]
[BEGIN]${STARTDATETIME}[/BEGIN]
[END]${ENDDATETIME}[/END]
[SECTION]NAME= \"${ServerName}\"[/SECTION]
[VALUE]DEATILS[/VALUE]" >>outputfile.txt
done

You need to hardcode something, being the values in your input really don't really resemble the values in your output.

Sorry, that was typo error. It is "Line".

Any preferences as to the tool to be used?

We can use awk or sed command.

Not too sophisticated, but may pass for a zeroth approach:

awk '
NR==FNR         {T[NR] = $0
                 MX = NR   
                 next   
                }

                {X = T[2]
                 Y = T[3]
                 Z = T[4]
                 sub ("]\[", "]" $2 " " $3 "[", X)
                 sub ("]\[", "]" $4 " " $5 "[", Y)
                 sub (/""/, "\"" $1 "\"",  Z)
                 print T[1]
                 print X
                 print Y
                 print Z   
                 print T[5]
                }
' file2 file1
[TYPE]SELECT[/TYPE]
[BEGIN]06/05/2016 10:00:00[/BEGIN]
[END]06/05/2016 05:08:59[/END]
[SECTION]NAME = "SERVER1"[/SECTION]
[VALUE]DEATILS[/VALUE]
[TYPE]SELECT[/TYPE]
[BEGIN]06/04/2016 09:50:00[/BEGIN]
[END]06/05/2016 01:03:59[/END]
[SECTION]NAME = "SERVER2"[/SECTION]
[VALUE]DEATILS[/VALUE]
[TYPE]SELECT[/TYPE]
[BEGIN]06/06/2016 11:26:00[/BEGIN]
[END]06/06/2016 10:31:55[/END]
[SECTION]NAME = "SERVER3"[/SECTION]
[VALUE]DEATILS[/VALUE]

Using my yanx.awk library I can substitute into appropriate tag names:

$ cat template.sh
#!/bin/bash

if [ -z "$2" ]
then
        echo "Usage:  $0 datafile templatefile" >&2
        exit 1
fi

while read NAME D1 T1 D2 T2 G
do
        awk -v DATA="BEGIN|$D1 $T1|END|$D2 $T2|SECTION|NAME = \"$NAME\"" \
                -f yanx.awk -e 'BEGIN {
                        RS="["; FS="]"; ORS=""; OFS="]";
                        N=split(DATA, DA, "|");
                        for(M=1; M<=N; M+=2) D[DA[M]]=DA[M+1]; }
                TAG in D { $2=D[TAG] } ; { print "[" $0 }' "$2"
done < "$1"

$ ./template.sh

Usage:  ./template.sh datafile templatefile

$ ./template.sh data template

[TYPE]SELECT[/TYPE]
[BEGIN]06/05/2016 10:00:00[/BEGIN]
[END]06/05/2016 05:08:59[/END]
[SECTION]NAME = "SERVER1"[/SECTION]
[VALUE]DEATILS[/VALUE]
[TYPE]SELECT[/TYPE]
[BEGIN]06/04/2016 09:50:00[/BEGIN]
[END]06/05/2016 01:03:59[/END]
[SECTION]NAME = "SERVER2"[/SECTION]
[VALUE]DEATILS[/VALUE]
[TYPE]SELECT[/TYPE]
[BEGIN]06/06/2016 11:26:00[/BEGIN]
[END]06/06/2016 10:31:55[/END]
[SECTION]NAME = "SERVER3"[/SECTION]
[VALUE]DEATILS[/VALUE]

$

The hardcoded bit, the part that transforms the variables as read into the tag names and values you want, is highlighted in red. It's formatted TAGNAME|TAGVALUE|TAGNAME|TAGVALUE .