dns_write_post.sh

pdm

New member
Joined
Sep 11, 2014
Messages
2
I'm using instructions (http://www.directadmin.com/features.php?id=450) but I'm stuck with my script.

The TXT entries are in url encoded arrays:
TXT=domain.com.="v=spf1 a mx ip4:15.16.17.18 ~all"&domain.com.=test
I'm using:
Code:
TXTS=(`echo $TXT | tr "&" "\n"`)
if [ ${#TXTS[@]} > 0 ]; then
for a in "${TXT[@]}"
do
   ${TXT[0]}  >> /tmp/defaultdns   
   ${TXT[1]}  >> /tmp/defaultdns
done

The loop return:
Code:
domain.com.="v=spf1 a mx ip4:15.16.17.18 ~all"
and
Code:
domain.com.=test

Now I'm trying again to explode first element in array but I cant becouse there are more than one "="

1. How to explode this or where to change default separator "=" to somethin more uniqe like "::"
2. Why the varible SRV is always empty ?
 
You are coding it wrong then. Find a better way to code it.
 
Why couldn't you just use "cut" ? Some of the examples:
Code:
[root@testing ~]# echo 'TXT=domain.com.="v=spf1 a mx ip4:15.16.17.18 ~all"&domain.com.=test' | cut -d= -f3,4 | cut -d\& -f1
"v=spf1 a mx ip4:15.16.17.18 ~all"

Code:
[root@testing ~]# echo 'TXT=domain.com.="v=spf1 a mx ip4:15.16.17.18 ~all"&domain.com.=test' | cut -d'"' -f2
v=spf1 a mx ip4:15.16.17.18 ~all

Code:
[root@testing ~]# echo 'TXT=domain.com.="v=spf1 a mx ip4:15.16.17.18 ~all"&domain.com.=test' | cut -d\& -f2
domain.com.=test
 
Back
Top