I'm very new to shell scripting, below is my output in status.txt
CM TARGET ACTUAL
---------------------------------- ---------- ----------
Conflict Resolution Manager 1 1
Internal Manager 1 1
Standard Manager 18 18
Workflow Agent Listener Service 1 1
Workflow Mailer Service 1 1
Output Post Processor 1 1
My requirement is to compare target and actual.
If any difference should send mail "$CM down" I know we can use awk and sed utilities but something else
like (if,then,else) also needs to be used.
That's where i'm not able to create logic.
Please help me in this.
Not getting desired output.
I'm executing the script as below.
---------------------------------
#!/bin/bash
awk 'NR>2' status.txt | while read line; do
if [ -n "`echo $line | awk '$NF!=$(NF-1)'`" ]; then
mail -s "$line" xyz@pqr.corp.com < /dev/null
fi
done
-------------------------------
I should get message like
$CM is down
awk 'NR>2' status.txt | while read line; do
if [ -n "`echo $line | awk '$NF!=$(NF-1)'`" ]; then
MSG="`echo $line | awk '{NF-=2}1'` is down"
mail -s "'$MSG'" xyz@pqr.corp.com < /dev/null
fi
done