Multiple command execution inside awk command during xml parsing
below is the output xml string from some other command and i will be parsing it using awk
Code:
cat /tmp/alerts.xml
<Alert id="10102" name="APP-DS-ds_ha-140018-componentFailure-S" alertDefinitionId="13982" resourceId="11427" ctime="1359453507621" fixed="false" reason="If Event/Log Level(ANY) and matching substring "failed on server" Log: 10.19.123.197: 0:25:48.04, 1.3.6.1.4.1.1453.4.9.1.3.0.1, The service has failed on this server and caused an HA failover to occur., CLR OCCAS failed on server 10.19.123.197, failure, 2013-01-29,04:58:27.6,--5:0, CLEAR, 10.19.123.197, failure, 2013-01-29,04:58:27.6,--5:0, CLEAR, The service has"/>
.
.
.
etc ect
ID=10102
NAME=APP-DS-ds_ha-140018-componentFailure-S
FIXED=false
DATE= 2013-01-29 04:58:27.6
AlDefID=13982
.
.
.etc etc many entries will be there
what i want to achieve is
>in the awk command i want to implement a check for date, first i will parse the date obtained from the query to only date and no time stamp and also system date
Code:
myDate=$( date --date="$DATE" +%Y%m%d )
sysDate=$( date +%Y%m%d )
and if this date is older than system date then dont print from awk
Code:
if [[ $myDate -eq $sysDate ]] ;then
print
else
skip all
fi
PS: i am not good at parsing xml so i did some my own awk and cut to get priority value from xml :-)
the above output is nothing but the priority obtained from that id and display it on console immediately.
--------------
so final output will be
Code:
ID=10102
NAME=APP-DS-ds_ha-140018-componentFailure-S
FIXED=false
DATE= 2013-01-29 04:58:27.6
AlDefID=13982
priority=3.
.
.etc etc many entries will be there
what i want to do is, use this hqapi.sh command inside mail xml parsing AWK command for each iteration and print priority then and there,
i tried using the hqapi command in quotes `` inside awk but it dint work.
any help on this will be deeply appreciated. thanks
PS:also if i succeed in all the above, is there any way i could use echo commands in awk so that i can put check in awk for printing priority in words say 1-lOW,2-MED,3HIGH in colour code using
Code:
echo -e "\e[1;31mHIGH\e[0m"
so the output
Code:
priority=HIGH
---------- Post updated at 09:37 PM ---------- Previous update was at 07:46 PM ----------
:-( dint help.
i just need the solution for running a script inside awk and storing the output in a variable and also using date variable inside awk for comparison. Is it possible?
I tried running this.
dsh -w server1 'lsof /audit | awk '{ print $2 }''
It did not like above so I tried to escape the single parenthesis at the end.
dsh -w server1 'lsof /audit | awk '{ print $2 }\''
It then hung so I changed up the parenthesis to this. This worked.
dsh -w server1... (6 Replies)
from the CLI on a Mac, if you type networksetup -listallnetworkservices then you get results in a multi-line paragraph that look something like this:
networksetup -listallnetworkservices
An asterisk (*) denotes that a network service is disabled.
Wi-Fi
Display Ethernet
Bluetooth DUN... (7 Replies)
Hi Experts,
How do I parse a XML with below contents
<saw:user name="mbussey@xyz.com" />
<saw:user name="kimmy.chan@pqr.com" />
<saw:user name="chudgins@gmail.com" />
and retrieve below output ?
mbussey@xyz.com
kimmy.chan@pqr.com
chudgins@gmail.com
... (17 Replies)
Hi All,
I am trying to find a word from a file in loop.
while read i; do
DB_Name=$i
awk '{for(i=1;i<=NF;i++)if($i~/$DB_Name/)print $(i)}' $BTEQ_NAME > $DB_Name_TableList.txt
done <Param.txt
here Param.txt contents data as
ODS_TARGT_RECV
FIN_TARGT... (7 Replies)
Hi,
I would like to use grep command inside awk.
Here is my requirement below :
file.txt
col1 col2 col3 col 4 col 5
wrxwrx 124 jun 3 Sensex.EMEA
wrxwrx 120 jun 4 Emex.US
wrxwrx 130 feb 3 passion.AUS
wrxwrx 145 feb 9 lession.AUS
wrxwrx 130 feb 5 pass.US
wrxwrx 130 feb 8... (5 Replies)
Hi all, I have the requirement to generate the file containing following command
eval /path/ dsjob -logdetail projectname JOBNAME /path/
1. The file contains the above command say about 150 times i,e only the JOBNAME changes in every command
2. The commands must be written in such a way... (2 Replies)
Hi All,
I have the following requirement. In a directory i get files from external source. I at regular intervals check that directory for any incoming files.
The file name is underscore delimited.
Such as:
aaa_bbb_ccc_ddd_eee_fff.dat
I am using awk and and splitting the file name. ... (4 Replies)
Hi All,
I have a awk command that is stored in a variable.
the value of the variable cmd is:
(mean output of echo $cmd is: )
awk -F";" '{print $1}'
Now I want to execute this command.
How can I do that????
Quick Reply will be appreciated.
Regards,
Amit (2 Replies)