Customize the Shell Script output

Hello guys.
i wan to write an script to Customize this output:

-------------------+--------------------+---------+---------
ias-component      | process-type       |     pid | status
-------------------+--------------------+---------+---------
DSA                | DSA                |     N/A | Down
LogLoader          | logloaderd         |     N/A | Down
dcm-daemon         | dcm-daemon         |    3948 | Alive
OC4J               | home               |    4207 | Alive
OC4J               | officeauto         |    3955 | Alive
OC4J               | gaas               |    4208 | Alive
OC4J               | report             |    3957 | Alive
OC4J               | workflow           |    3953 | Alive
OC4J               | messenger          |    3950 | Alive
OC4J               | archive            |    3956 | Alive
OC4J               | GamWS              |    3958 | Alive
OC4J               | menu               |    3949 | Alive
OC4J               | sws                |    3952 | Alive
WebCache           | WebCache           |    4070 | Alive
WebCache           | WebCacheAdmin      |    4209 | Alive
HTTP_Server        | HTTP_Server        |    3951 | Alive

to something like this:

Home=1(if its Alive and 0 if its down)
officeauto=1
.
.
.

I'mnew in Linux scripting and really appropriate any sort of help.
thank you gays.

I'm not at all sure that I understand what you're trying to do.

You say you want to print Home=1 (if it is Alive ) or Home=2 (if it is down , but down with a lowercase d does not appear anywhere in your input), but instead of printing DSA=2 , you printed nothing??? You say the first line of the output should be Home=1 , but Home (with an uppercase H ) does not appear anywhere in your input data???

Please give a clearer description of what output you hope to produce from this output. Please tell us what form this output takes. (Is it a string in a shell variable? Is it being written to a pipe by some other process? Is it stored in a file?) Please tell us what you want to do with the transformed output.

No attempts nor ideas from your side?
However, try

awk -F\| 'NR>3{gsub (/ /,_); print $2 "=" ($4=="Alive")}' file
DSA=0
logloaderd=0
dcm-daemon=1
home=1
officeauto=1
gaas=1
report=1
workflow=1
messenger=1
archive=1
GamWS=1
menu=1
sws=1
WebCache=1
WebCacheAdmin=1
HTTP_Server=1

Or:

awk -F' *[|] *' '$4=="Down"{print $2 "=" 0} $4=="Alive"{print $2 "=" 1}' file

Thank you so much dear Don, Rudic and Scurit.
let me explain my problem again:
i want to execute this command and then customize the output.

output=$(su - oracle -c'/oracleAS10g/product/opmn/bin/opmnctl status')

the output is the same one i posted in my first thread.
i guess awk need a file but i just want to analyze the command output.

thank you.

Please use code tags as required by forum rules!

Please make yourself familiar with "redirection" and "pipes" in *nix, e.g. man sh/bash/ksh .
Try

su - oracle -c'/oracleAS10g/product/opmn/bin/opmnctl status' | awk -F\| 'NR>3{gsub (/ /,_); print $2 "=" ($4=="Alive")}'

Thank you dear RudiC.
would you lease explain little bit your code?
the output has a little problem but it worked.
i want to try split the command and fix the problem. i use this one but it didnt work:

output=$(su - oracle -c'/oracleAS10g/product/opmn/bin/opmnctl status')
echo $output | awk -F\| 'NR>3{gsub (/ /,_); print $2 "=" ($4=="Alive")}'

the command output is:

=0
process-type=0
=0
DSA=0
logloaderd=0
dcm-daemon=1
home=1
officeauto=1
gaas=1
report=1
workflow=1
messenger=1
archive=1
GamWS=1
menu=1
sws=1
WebCache=1
WebCacheAdmin=1
HTTP_Server=1
=0

Try:

echo "$output"

Looks like your output variable contains more lines than your sample in post #1. The first three items seem to reflect the header of your status which should be excluded by NR>3.

awk -F\|                        # run awk with "|" as the field separator
'                               # start of first parameter (program text)
NR>3                            # pattern 1: skip lines 1 - 3 incl., TRUE above 3. line
{                               # open the action 1
gsub (/ /,_);                   # replace spaces with nothing (_ is an undefined thus empty variable)
 print $2 "=" ($4=="Alive")     # print 2. field, "=", and the logical value (0/1) of the comparison
}                               # close action 1
'                               # close first parameter

Than you so much.
honestly i didn't think this can be done!!
this is one of the best forums I ever seen for help and response.

Thank you again.

Hello Ymir,

One more solution on same may help you.

awk -F"|" '(NR>3 && ($4 ~ /Down/ || $4 ~ /Alive/)){A=$4==" Down"?$2 OFS "0":$2 OFS "1";print A}' Input_file

Output will be as follows.

 DSA                 0
 logloaderd          0
 dcm-daemon          1
 home                1
 officeauto          1
 gaas                1
 report              1
 workflow            1
 messenger           1
 archive             1
 GamWS               1
 menu                1
 sws                 1
 WebCache            1
 WebCacheAdmin       1
 HTTP_Server         1

Thanks,
R. Singh