小编Vin*_*nod的帖子

用sed替换xml值

我想替换XML文件中的值.示例XML

<Console>
                <!-- REQUIRED PARAMETERS -->
                <!-- Enter the node that you are running the installation program from. This value must be a fully qualified name, which includes a host name and domain name. For example, node001.server.name.com.-->
                <node>node.sample.ibm.com</node>

                <!-- Enter the domain name of the cluster as a single dot-separated string. For example, server.name.com. -->
        <sso-domain-name>sample.ibm.com</sso-domain-name>

        <!-- Set this property to true if your InfoSphere BigInsights Console uses HTTPS. Otherwise, enter false. -->
                <https>false</https>

        <!-- management-console-port specifies which port is …
Run Code Online (Sandbox Code Playgroud)

xml bash sed

4
推荐指数
2
解决办法
2万
查看次数

使用厨师的sed命令

嗨,我在厨师食谱中使用sed命令,但它抛出错误。但是,如果我在CLI上仅运行sed命令,它就可以工作。任何帮助表示赞赏。

我的sed命令是-

sed -i -e "/<BigSQL>/,/<\/BigSQL>/ s|<username>[0-9a-z.]\{1,\}</username>|<username>bigsql</username>|" /home/biadmin/install.xml
Run Code Online (Sandbox Code Playgroud)

我的厨师食谱是-

bash "change_bigsqluser" do
user "root"
code <<-EOH
sed -i -e "/<BigSQL>/,/<\/BigSQL>/ s|<username>[0-9a-z.]\{1,\}</username>|<username>bigsql</username>|" /home/biadmin/install.xml
EOH
end
Run Code Online (Sandbox Code Playgroud)

这是错误

Error executing action `run` on resource 'bash[change_bigsqluser]'
================================================================================


Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of "bash"  "/tmp/chef-script20140807-4025602-160wvt2" ----
STDOUT:
STDERR: sed: -e expression #1, char 15: unknown command: `B'
---- End output of "bash"  "/tmp/chef-script20140807-4025602-160wvt2" ----
Ran "bash"  "/tmp/chef-script20140807-4025602-160wvt2" returned 1


Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/biginsights/recipes/temp.rb …
Run Code Online (Sandbox Code Playgroud)

xml linux sed chef-infra

2
推荐指数
1
解决办法
2360
查看次数

标签 统计

sed ×2

xml ×2

bash ×1

chef-infra ×1

linux ×1