【发布时间】:2014-09-23 03:55:36
【问题描述】:
我正在尝试使用 shell 脚本从以下输出中检索对象的状态(Name 字段的值和 OpState 字段的值对应相同)。例如在上面的输出中的状态“DP-UID-FSH”的“向上”。我想产生如下输出:
平台:Solaris 上的 Bash。
DP-UID-FSH is up.
DP-Cert-FSH is up.
以下是需要解析以产生上述输出的文件内容。
<ConfigState>saved</ConfigState></ObjectStatus><ObjectStatus xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<Class>HTTPSSourceProtocolHandler</Class>
<OpState>up</OpState>
<AdminState>enabled</AdminState>
<Name>DP-UID-FSH</Name>
<EventCode>0x00000000</EventCode>
<ErrorCode/>
<ConfigState>saved</ConfigState></ObjectStatus><ObjectStatus xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<Class>SLMAction</Class>
<OpState>up</OpState>
<AdminState>enabled</AdminState>
<Name>DP-Cert-FSH</Name>
<EventCode>0x00000000</EventCode>
<ErrorCode/>
<ConfigState>saved</ConfigState></ObjectStatus><ObjectStatus xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<Class>SLMAction</Class>
<OpState>up</OpState>
<AdminState>enabled</AdminState>
<Name>shape</Name>
<EventCode>0x00000000</EventCode>
<ErrorCode/>
保存
我是 shell 脚本的新手,不知道如何实现这一点?
【问题讨论】:
-
嗨,请看我的问题。我的要求不一样。它不是关于解析 xml.Tirle 我的问题可能会产生误导,我会编辑相同的。
标签: bash perl shell awk solaris