Hi Guys,
I have written a script, which output information from email notfication. The output works fine in HTML format, but non-html format it is not shown in a human readable format.
Can you help with the format ***
Script
echo " Server Name : $CLIENT_CHECK " >> $OUTF
*** echo " Server Name :"| awk '{printf %-45s\n, $CLIENT_CHECK " >> $OUTF
echo " Policy Name : $POLICY_CHECK " >> $OUTF
echo " Schedule : $SCHEDULE_CHECK " >> $OUTF
Output
Server Name : sv203861
*** Server Name : | awk '{printf %-45s\n ,sv203861 '}
Policy Name : PROJECT_FOCUS
Schedule : FULL
Let me explain better, the following output comes out fine, and is displayed ok, if the user has his email set to HTML format. I am trying to cater for people who have not done this.
echo " Server Name : $CLIENT_CHECK " >> $OUTF
echo " Policy Name : $POLICY_CHECK " >> $OUTF
echo " Schedule : $SCHEDULE_CHECK " >> $OUTF
When i rewrite the code, to ensure the variable $CLIENT_CHECK is shown in column 45 spaces, it does not work
*** echo " Server Name :"| awk '{printf %-45s\n, $CLIENT_CHECK ' >> $OUTF
Output
Server Name : | awk '{printf %-45s\n ,sv203861 '}
Can you help so i get something like this
Desired Output
Server Name : sv203785
Policy Name : PROJECT_FOCUS2
Not Desired Output
Server Name : sv203785
Policy Name : PROJECT_FOCUS2
It looks like you have got yourself confused with your statement that has the awk in it. The | makes the output of the echo to become the input for the awk. The problem is, your awk does not use this input. This is what you need:
echo $CLIENT_CHECK | awk '{printf " Server Name : %-45s\n", $1}' >> $OUTF
The $CLIENT_CHECK is now sent in as the input and is referenced by the awk command using the $1.
Here again I am not sure what you are trying to do with the %-45s formatting. To me, RudiC's solution seems to be the cleanest. Trying to use awk just complicates things.
printf " Server Name : %s\n" $CLIENT_CHECK >> $OUTF