Perl 脚本中的 XML 编辑 [英] XML editing inside a Perl script
本文介绍了Perl 脚本中的 XML 编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 perl -pi -e 来编辑 xml 文件中的一行.如果我从命令行运行 perl -pi -e 命令它工作正常,但是一旦我放入我的脚本并使用系统命令,我就会得到下面列出的错误:
I am trying to us the perl -pi -e to edit the a line in a xml file. If I run the perl -pi -e command from the command line it works fine, but once I put in my script and use the system command I get the error listed below:
su: 无效选项 -- i
su: invalid option -- i
尝试su --help"以获取更多信息.
Try `su --help' for more information.
print "Please enter virtualhost 1 - Example - ucisha.com:";
my $virtualhost1 = <>;
system("ssh -t <HOST> \"sudo su - root -c perl -pi -e 's/xmlNamespaceAware=\"false\">/xmlNamespaceAware=\"false\"> <Alias>$virtualhost1<\/Alias>/g' /tcserver/springsource-tc-server-node/UCISjvm/conf/krh.xml\"");
推荐答案
您需要在传递给 -c
的参数周围添加引号.
You need to add quote marks around the argument you pass to -c
.
目前你有 -c perl
然后 -pi
被当作 su
的另一个参数而不是 perl代码>.
At the moment you have -c perl
and then -pi
is taken as another argument to su
not perl
.
这篇关于Perl 脚本中的 XML 编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文