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

Remote script over ssh execution issues.

$
0
0
If I execute below code I am able to get string from column8 and column10 about a process.

Code:

serverA1$> ps -ef | grep rotate | grep 'config' | awk '{print $8" "$10}'
/<Oracle_home>/ohs/bin/odl_rotatelogs -h:/<app_Home>/config/OHS/ohs1/component_events.xml_ohs1
/<Oracle_home>/ohs/bin/odl_rotatelogs -h:/<app_Home>/config/OHS/ohs1/component_events.xml_ohs2
/<Oracle_home>/ohs/bin/odl_rotatelogs -h:/<app_Home>/config/OHS/ohs1/component_events.xml_ohs3


servers
Code:

serverA1
serverB1
serverC1

But when I try to execute below script to execute same command on multiple servers, I am getting "0"s instead of column8 and column10. I think block of lines execution syntax does not like --> $8" "$10 in awk.

Code:


#!/bin/bash
for server in `cat servers` ; do
sudo ssh $server "bash -s" << EOF
echo "server=$server"
ps -ef | grep rotate | grep 'config' | awk '{print $8" "$10}'
EOF
done

How can I print output from each server in this format?
Code:

--> $server, $column8, $column10

Moderator's Comments:
Please use CODE tags, not ICODE tags

Viewing all articles
Browse latest Browse all 16232

Trending Articles