[CentOS] Script Output Format

m.roth at 5-cent.us m.roth at 5-cent.us
Wed Dec 29 17:59:05 UTC 2010


Alejandro Rodriguez Luna wrote:
> i'm just did a script that the output must be comma separated to be
> imported into a spreadsheet.
>
> the output that i obteined was
>
> Date/Time,We. Active Threads,W. Total Threads,W. Worker Threads,Name
> 29-12-10/11:43:01,0,250,0,/FIM
> ,0,/mytest
> ,0,/mockofprod/financing/customercentre
> ,0,/mockofprod/financing/commercial/amt
> ,0,/account/orderstatus
> ,0,/activities
>
> as you can see, the first row it's ok, but the second and third, etc etc,
> are not formated. any ideas of how can i achive this?
>
> NOTE: the first three values are simple commands that i put in order, the
> fourth and fifth are from a file.
>
> this is part of the code.
>
>
> printf "%s,%d,%d" $DATE $WSAT $WSTT >> output.${STANZA}.txt
>
> for i in `cat jlist.${STANZA}.txt`
> do
>   JUNCTION=${i}
>   WSWJ=`pdadmin -a sec_master -p ${PASSWD} server task ${STANZA} show
> ${JUNCTION} | grep 'threads' | awk '{ print $4 }'`
>   printf ",%d,%s\n" ${WSWJ} ${JUNCTION} >> output.${STANZA}.txt
> done

Well, it looks like $WSWJ is null. What's the output... hmmm, consider
that there may be more than one line with "threads", and that the fourth
element of the last line may not be what you want. (And you *could* just
do ...| awk {if ($0 ~ /threads/) { print $4;}}`)

         mark




More information about the CentOS mailing list