lazyrunner50
Programmer
I am trying to use ssh to log in to several linux boxes, check if the processes are running on each, and if a process is down on any one of the boxes, shut down all the processes on all the boxes, and then bring them all back up again.
Here's what I have so far:
The problem is, I can manualy ssh to the box, and run the command after ssh to get the process number, but I can't run the whole command in one line. Nothing is echoed out when I do that..
What I need is to be able to access $num outside of the call to ssh so that I can say something like
Here's what I have so far:
Code:
ssh userName@remoteBox "num=`ps -ef | grep userName | grep -i processName | grep -v grep | awk '{print $2 }'`; echo $num"
The problem is, I can manualy ssh to the box, and run the command after ssh to get the process number, but I can't run the whole command in one line. Nothing is echoed out when I do that..
What I need is to be able to access $num outside of the call to ssh so that I can say something like
Code:
ssh userName@remoteBox "num=`ps -ef | grep userName | grep -i processName | grep -v grep | awk '{print $2 }'`; echo $num"
if [ $num ] ; then
shutdownFlag=1
echo "Shutdown flag is set!"
fi