I created a script that will go out and so a "/sbin/chkconfig --list | egrep XXX" against a server list that would create an output file like the following example:
----------------------------------------------------------------------------------
SERVER1
RC_Script_1 0:off 1:off 2:off 3:on 4:off 5:off 6:off
RC_Script_2 0:off 1:off 2:off 3:on 4:off 5:off 6:off
Connection to SERVER1 closed.
----------------------------------------------------------------------------------
SERVER2
RC_Script_1 0:off 1:off 2:off 3:on 4:off 5:off 6:off
Connection to SERVER2 closed.
----------------------------------------------------------------------------------
I would like to create a CSV file so that when I open it I would have something like:
SERVER1, RC_Script_1, etc
SERVER2, RC_Script_1, etc
One problem is a server might have no RC Script(s), Three, or more...
Try this
your_script | awk '/^-/ { getline; S=$1 ; next }
S && /Connection/ {S=0}
S {print S","$1", etc" }'
That did not seem to work
In my script I have
done | tee -a ${logfile}
at the end. I tried running the above after commenting out the logfile. I get the following back:
,, etc862
,RC_Script1, etc
,RC_Script2, etcSERVER1
,RC_Script3, etcs863
Connection to SERVER1 closed.
,, etc863
,RC_Script1, etc
Connection to SERVER2 closed.
,RC_Script2, etc
,, etc866
,RC_Script, etc
,RC_Script1, etcSERVER3
,was-appservers, etcSERVER3
,was-dmgr, etc SERVER3
,RC_Script2, etcSERVER3
,was-nodeagent, etcSERVER3
,RC_Script3, etcSERVER3
Connection to SERVER3 closed.
Looks like the output doesn't match what you have in post #1.
Of particular importance is the line of dash ("-") characters starting a column 1
I double checked and this is a part of the output file:
SERVER1
RC_Script_1 0:off 1:off 2:off 3:on 4:off 5:off 6:off
----------------------------------------------------------------------------------
SERVER2
RC_Script_1 0:off 1:off 2:off 3:on 4:off 5:off 6:off
----------------------------------------------------------------------------------
SERVER3
RC_Script_1 0:off 1:off 2:off 3:on 4:off 5:off 6:off
----------------------------------------------------------------------------------
SERVER4
RC_Script_1 0:off 1:off 2:on 3:on 4:off 5:on 6:off
RC_Script_2 0:off 1:off 2:on 3:on 4:off 5:on 6:off
----------------------------------------------------------------------------------
SERVER5
RC_Script_1 0:off 1:off 2:on 3:on 4:off 5:on 6:off
RC_Script_2 0:off 1:off 2:on 3:on 4:off 5:on 6:off
----------------------------------------------------------------------------------
SERVER6
RC_Script_1 0:off 1:off 2:off 3:on 4:off 5:off 6:off
----------------------------------------------------------------------------------
Would it be easier if I had the server name on each line ?
EX:
SERVER1 RC_Script_1 0:off 1:off 2:off 3:on 4:off 5:off 6:off
----------------------------------------------------------------------------------
SERVER2 RC_Script_1 0:off 1:off 2:off 3:on 4:off 5:off 6:off
----------------------------------------------------------------------------------
SERVER3 RC_Script_1 0:off 1:off 2:off 3:on 4:off 5:off 6:off
----------------------------------------------------------------------------------
SERVER4 RC_Script_1 0:off 1:off 2:on 3:on 4:off 5:on 6:off
SERVER4 RC_Script_2 0:off 1:off 2:on 3:on 4:off 5:on 6:off
----------------------------------------------------------------------------------
SERVER5 RC_Script_1 0:off 1:off 2:on 3:on 4:off 5:on 6:off
SERVER5 RC_Script_2 0:off 1:off 2:on 3:on 4:off 5:on 6:off
----------------------------------------------------------------------------------
SERVER6 RC_Script_1 0:off 1:off 2:off 3:on 4:off 5:off 6:off
----------------------------------------------------------------------------------