I'm trying to run some commands from ssh. There are multiple variables in each remote server.
for db_serv in `olsnodes`; do
for db_ins in `ssh $db_serv ps -ef | grep ora_pmon_ | grep -v grep | cut -d"_" -f3`; do
SessionSayisi=`ssh $db_serv ps -ef | grep $db_ins | grep 'LOCAL=NO'|grep -vc ASM`
echo "SessionSayisi= $SessionSayisi $db_ins"
done
done
This works well but takes long time because the command is running ssh for each variable. I need to connect only one time for each server, then get all variable outputs, then ssh to another.
Here is what i tried but it didn't work:
for db_serv in `olsnodes`; do
ssh $db_serv ps -ef | grep ora_pmon_ | grep -v grep | cut -d"_" -f3 << EOF
for db_ins in `ps -ef | grep ora_pmon_ | grep -v grep | cut -d"_" -f3`; do
echo "SessionSayisi= $SessionSayisi $db_ins"
done
EOF
done