parsing data from xml file is failing can't open variable

Created a korn shell script, everything is is working except this section, the variable $SYSINFO is being set, but the NASIP & NASDEV are failing, it appears to be treating the config.xml file config directory and xml as the file. Need a second set of eyes to tell me where I am messing up.

# Start NAS Interface Config
SYSINFO="/vm/$zonename/root/var/sysinfo"
echo $SYSINFO
NASIP="`/bin/sed -n -e 's/.*<nasip>\(.*\)<\/nasip>.*/\1/p' $SYSINFO/config.xml`"
NASDEV="`/bin/sed -n -e 's/.*<nasdevice>\(.*\)<\/nasdevice>.*/\1/p' $SYSINFO/config.xml`"
echo $NASDEV
zonecfg -z $zonename 'add net; set address=$NASIP; set physical=$NASDEV;end'

This is the output from this section of the script.

/vm/server04z1/root/var/sysinfo    ----> echo $SYSINFO
Can't open /vm/server04z1/root/var/sysinfo/config  ---> should be parsing config.xml
Can't open xml
Can't open /vm/server04z1/root/var/sysinfo/config   ---> should be parsing config.xml
Can't open xml

Can you remove the double quotes around the variable expression substitution as below

NASIP=`/bin/sed -n -e 's/.*<nasip>\(.*\)<\/nasip>.*/\1/p' $SYSINFO/config.xml`
NASDEV=`/bin/sed -n -e 's/.*<nasdevice>\(.*\)<\/nasdevice>.*/\1/p' $SYSINFO/config.xml`

cheers,
Devaraj Takhellambam

I had word splitting turn on for (.) IFS=. for IP translation within the same script. Which config.xml was splitting so I just inserted an escape character (\) and it's working.

NASIP="`/bin/sed -n -e 's/.*<nasip>\(.*\)<\/nasip>./\1/p' ${SYSINFO}/config\.xml`"
NASDEV="`/bin/sed -n -e 's/.*<nasdevice>\(.*\)<\/nasdevice>.
/\1/p' ${SYSINFO}/config\.xml`"

I am glad you were able to figure out and its working now :slight_smile: