I find it difficult to believe that above sed script worked the desired way. Within single quotes, shell variables are not expanded, so the literal values like ${REQ1} would be inserted into the output:
I gave only example in earlier post, not full of my script. I ma trying understand the logic to implement, I Will declare the values in script,how to pars the values my script will take care.
At the end i am looking a command to update the values at XML file...
---------- Post updated at 06:02 PM ---------- Previous update was at 04:03 PM ----------
Hi Rudi,
You are correct, my script is inserting ${REQ1} values only.. help me the right command to use.
I have used XMLSTARTLET package and used the bellow command, still no luck,
Code:
xml ed -u '/task-arguments/argument[@name="protocol"]/@default-value' -v 'string("tcp")' /tmp/test_xml/monitor.xml
xml ed -u '/task-arguments/argument[@name="port"]/@default-value' -v 'string("7223")' /tmp/test_xml/monitor.xml
xml ed -u '/task-arguments/argument[@name="username"]/@default-value' -v 'string("test")' /tmp/test_xml/monitor.xml
i am getting bellow error,
Code:
./sed.sh: line 4: 23932 Segmentation fault xml ed -u '/task-arguments/argument[@name="protocol"]/@default-value' -v 'string("tcp")' /tmp/test_xml/monitor.xml
./sed.sh: line 5: 23933 Segmentation fault xml ed -u '/task-arguments/argument[@name="port"]/@default-value' -v 'string("7223")' /tmp/test_xml/monitor.xml
./sed.sh: line 6: 23934 Segmentation fault xml ed -u '/task-arguments/argument[@name="username"]/@default-value' -v 'string("test")' /tmp/test_xml/monitor.xml
please help me on this..
---------- Post updated at 06:07 PM ---------- Previous update was at 02:20 PM ----------
Hi Rudi,
The below one help me achieve my requirement..Thanks for your time
Code:
#!/bin/sh
xmlfile_in="data.xml"
xmlfile_out="data.new"
protocol="tcp"
port="7223"
user="test"
sed -f /dev/stdin "$xmlfile_in" >"$xmlfile_out" <<END_SED
/argument name="protocol"/{
i\\
<argument name="protocol" is-required="true" default-value="$protocol"/>
d
}
/argument name="port"/{
i\\
<argument name="port" is-required="true" default-value="$port"/>
d
}
/argument name="username"/{
i\\
<argument name="username" is-required="true" default-value="$user"/>
d
}
END_SED
Last edited by RudiC; 07-11-2016 at 09:34 AM..
Reason: Add CODE and ICODE tags (again and again)
Dear community,
I have a big XML log file containing several rows splitted by tag: <ActivityLogRecord> and </ActivityLogRecord>. An example below.
What I need is read the file and extract some value from each tags and put them into one line (each line for every <ActivityLogRecord> tag).
So... (5 Replies)
hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file
<sequence>
<Filename>aldorzum.doc</Filename>
<DivisionCode>US</DivisionCode>
<ContentType>Template</ContentType>
<ProductCode>VIMZIM</ProductCode>
</sequence>... (4 Replies)
hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file
<sequence>
<Filename>aldorzum.doc</Filename>
<DivisionCode>US</DivisionCode>
<ContentType>Template</ContentType>
<ProductCode>VIMZIM</ProductCode>
</sequence>... (1 Reply)
Hi All,
I have two xml files.
One is having below input
<NameValuePair>
<name>Daemon</name>
<value>tcp:7474</value>
</NameValuePair>
<NameValuePair>
<name>Network</name>
<value></value>
</NameValuePair>
... (2 Replies)
Hi,
I need to capture all the attributes with delete next to it. The source XML file is attached.
The output should contain something like this below:
Attributes = legacyExchangeDN
Action = Delete
Username = Hero Joker
Loginid = joker09
OU =... (4 Replies)
Hello I am a noob in XML and Python. I am trying to do this for my MSc project about a network simulation and need some help.... I want to change the values shown below:
<num_crash_failures>1</num_crash_failures>
−<crash_failure_entry>
<freeze_at_slot>0</freeze_at_slot>... (0 Replies)
Hello,
I don't have experience in this scripting and I need some help to read a value from an XML file and change it with a random number to use in simulator for different network scenarios.
</Description><sim_comm_rounds>35</sim_comm_rounds><num_clusters>1</num_clusters><Clocking>
I want to... (5 Replies)
Hi,
I am new to UNIX and shell scripting.
I have to create a shell script(ksh) which parses log4j.xml file for a given webservice name and change the corresponding value from INFO to DEBUG or vice-versa.
My log4j.xml looks like:-
<!-- Appender WEBSERVICENAME-->
<appender... (3 Replies)
Hello People,
I have an xml file from which I need to extract the values of the parameters using UNIX shell commands.
Ex : Input is like :
<Name>Roger</Name>
or
<Address>MI</Address>
I need the output as just :
Roger
or
MI
with the tags removed.
Please help. (1 Reply)