Loop through servers and run command
You need to redirect the stdin of SSH command in your loop to nowhere to prevent reading all your lines. This should do it:
http_status=$(ssh $name "ps -ef | grep -v grep | grep $service | wc -l" < /dev/null)
There is solution with -n -x
parameters:
http_status=$(ssh -nx name ps -ef | grep -v grep | grep $service | wc -l)
The -x
disables X11 forwarding to get rid of possible X11 forwarding request failed
messages.
The -n
redirects stdin from /dev/null (actually, prevents reading from stdin).