Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Interpreting multiple values from a variable

$
0
0
Hi,

I am writing a shell script which will check the status of a resource in a cluster and then display nicely to a user running the script at command line.

Basically the script runs a status command and then pulls certain keywords from the return and then should display a concise status.

My current code:

Code:

appVstatus=`scstat -g | grep ITM | grep $DC | awk '{print $2 "|" $5}'`
oldIFS="IFS"
IFS='|'
echo $appVstatus
 
    echo $appVstatus | (while read -r processname status; do
    echo "$processname is $status"
    done)

This results in :

Code:

CREST06QM_A_ITM Online
CREST06_HUBC3_A_ITM Online
CREST06_HUBC4_A_ITM Online
CREST06QM_A_ITM Online is
CREST06_HUBC3_A_ITM Online is
CREST06_HUBC4_A_ITM Online is

What I am actually looking for is:

Code:

CREST06QM_A_ITM Online
CREST06_HUBC3_A_ITM Online
CREST06_HUBC4_A_ITM Online
CREST06QM_A_ITM is Online
CREST06_HUBC3_A_ITM is Online
CREST06_HUBC4_A_ITM is Online

Any ideas would be gratefully received. I'm going round in circles on this one!

Viewing all articles
Browse latest Browse all 16232

Trending Articles