result="<RETURN status="FAILED" number="5101">Invalid value for 'add_host_ips' : 192.168.1.55 (not assigned to AG owner). IPs do not exist in the license or user account.</RETURN>"
I just want to isolate status="FAILED" and assign failed to a variable.
Seems simple, but i dont know really well scripting hence unable to do it.
Any help would be greatly appreciated.
Thanks in advance.
Sorry guys for the trouble; but there is still an error:
result="<RETURN status="FAILED" number="5101">Invalid value for 'add_host_ips' : 192.168.1.55 (not assigned to AG owner). IPs do not exist in the license or user account.</RETURN>"
sed 's/^.*status="\([^"]*\)".*$/\1/')
echo $status
#out put:
#<RETURN status=FAILED number=5101>Invalid value for 'add_host_ips' : 192.168.1.55 (not assigned to AG owner). IPs do not exist in the license or user account.</RETURN>
---------- Post updated at 09:57 AM ---------- Previous update was at 09:55 AM ----------
result="<RETURN status="FAILED" number="5101">Invalid value for 'add_host_ips' : 192.168.1.55 (not assigned to AG owner). IPs do not exist in the license or user account.</RETURN>"
status=$(echo $result |sed 's/^.*status="\([^"]*\)".*$/\1/')
echo $status
out put:
<RETURN status=FAILED number=5101>Invalid value for 'add_host_ips' : 192.168.1.55 (not assigned to AG owner). IPs do not exist in the license or user account.</RETURN>
Your assignment of the literal value is not being interpreted the way you think it is, the double quotd are being interpreted by the shell.
Try asssgning the value to result from a process directly, or compare to the snippet below:
result='<RETURN status="FAILED" number="5101">Invalid value for "add_host_ips" : 192.168.1.55 (not assigned to AG owner). IPs do not exist in the license or user account.</RETURN>'
status=$(echo $result|sed 's/^.*status="\([^"]*\)".*$/\1/')
echo $status