bashシェルスクリプトからXMLファイルを編集したいですか? 私は解決策を見つけ出すことに固執しています。これがbashシェルスクリプトで解決できる場合は、あなたの提案を分かち合いましょう。bashシェルからXMLファイルを編集する
入力ファイル(サーバーに保存されます):それはDcustom.properties =/FS0 /を持っている場合、私はapplicationServerInstanceタグを検索して見てみたかった上記のスニペットで
<?xml version="1.0" encoding="UTF-8"?>
<properties>
\t <directories installDir="/fs0/">
\t \t <directoriesInstance id="sharedDir" path=""/>
\t \t <directoriesInstance id="loaderInput" path="/fs0/share/iad/input"/>
\t \t <directoriesInstance id="loaderProcessing" path="/fs0/share/iad/processing"/>
\t \t <directoriesInstance id="loaderError" path="/fs0/share/iad/error"/>
\t \t <directoriesInstance id="loaderCompleted" path="/fs0/share/iad/completed"/>
\t </directories>
<applicationServerInstance id="app" serviceName="App Server" rmiPort="15001" jvmParameters="-Xmx3072m -Xms512m -XX:-UseGCOverheadLimit -XX:MaxPermSize=196m -Dsun.lang.ClassLoader.allowArraySyntax=true -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/fs0/clarity1/clarity/logs -Xloggc:/fs0/clarity1/clarity/logs/app_gc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -Dcustom.properties=/fs0/share/custom.properties" maxThreads="1000" programParameters="" distributed="false" runJobScheduler="false" useSSO="true" maxConcurrentJobs="10" runProcessEngine="false" messageTimeToLive="120" messageReceiverInterval="5" exceptionRunInterval="normal" maxXmlNodesLimit="150000"/>
<applicationServer>
\t \t <applicationServerInstance id="app" serviceName=" App Server" rmiPort="15001" jvmParameters="-Xmx3072m -Xms512m -XX:-UseGCOverheadLimit -XX:MaxPermSize=196m -Dsun.lang.ClassLoader.allowArraySyntax=true -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/fs0/clarity1/clarity/logs -Xloggc:/fs0/clarity1/clarity/logs/app_gc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -Dcustom.properties=/fs0/clarity1/share/custom.properties" maxThreads="1000" programParameters="" distributed="false" runJobScheduler="false" useSSO="true" maxConcurrentJobs="10" runProcessEngine="false" messageTimeToLive="120" messageReceiverInterval="5" exceptionRunInterval="normal" maxXmlNodesLimit="150000"/>
\t </applicationServer>
</properties>
jvmpropertiesタグのclarity1/share/custom.properties - それが存在しない場合は、ファイルに追加してファイルを保存したかったのです。 すべてはbashシェルスクリプトでなければなりません。
私はそれが存在しない場合はapplicationServerInstanceタグでjvmParameters属性に-Dcustom.properties =/FS0 /共有/ custom.propertiesに値を追加します。上記の例ではこの値を持っていますが、存在しない場合は-Dcustom.properties =/fs0/share/custom.propertiesの値を追加します。
例と言う私はjvmParameters以下のスニペットにapplicationServerInstanceタグの属性に-Dcustom.properties =/FS0 /共有/ custom.propertiesに値を追加しなければなりません。あなたのXMLファイルで
<applicationServerInstance id="app" serviceName=" App Server" rmiPort="15001" jvmParameters="-Xmx3072m -Xms512m -XX:-UseGCOverheadLimit -XX:MaxPermSize=196m -Dsun.lang.ClassLoader.allowArraySyntax=true -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/fs0/clarity1/clarity/logs -Xloggc:/fs0/clarity1/clarity/logs/app_gc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC " maxThreads="1000" programParameters="" distributed="false" runJobScheduler="false" useSSO="true" maxConcurrentJobs="10" runProcessEngine="false" messageTimeToLive="120" messageReceiverInterval="5" exceptionRunInterval="normal" maxXmlNodesLimit="150000"/>
'jvmproperties' *タグはありませんが、値は' jvmParameters' *属性*に含まれています。値を追加するか、既存の 'custom.properties'を置き換えますか? – choroba
** --Dcustom.properties =/fs0/share/custom.properties **の値を** jvmParameters **属性に** appServerServerInstance **タグに追加します。上記の例ではこの値を持っていますが、存在しなければこの** - Dcustom.properties =/fs0/share/custom.properties **の値を追加したいと思います。 – Naga
コマンドラインXML処理については、xmlstarletを参照してください。 –