Getting remote variables more efficiently

Hello all,

I have a script that has to get variables remotely. Rather than having the script login to the remote server 3 separate times, is there a faster way to get each variable?


##Server comes from input or list##


CHKINSTALL=`ssh server "swlist | grep -i program" | grep -v Running | awk '{print $1}'`
CHKVERSION=`ssh server "swlist | grep -i program" | grep -v Running | awk '{print $2}'`
CFEPROCESS=`ssh server "ps -ef | grep -i program > /dev/null ; echo $?" | grep -v -e grep -e Running`

Hi
Considering the first two,(not sure about the output which you are expecting from the thrid)

INST_VER=`ssh server "swlist | grep -i program" | grep -v Running | awk '{print $1, $2}'`

CHKINSTALL=`echo $INST_VER | awk '{print $1}'`
CHKVERSION=`echo $INST_VER | awk '{print $2}'`

not tested though...

Guru.

1 Like

I tested it. It worked. Thanks!!

For the third, I am checking to see if there are any processes on the remote server, and capture the return code for the command. Have any ideas on how to include that one as well?