Reputation: 1120
I want to make multiple check depend on the result to make different actions.
In that case something is going wrong:
ssh 10.1.1.1 'sapi=`ps -ef | grep weblogic | grep sapi | grep -v grep | wc -l`;if [ ! $sapi ]; then printf "unknown";elif [ "$sapi" == "0" ]; then printf "inactive";else printf "active";fi'
The idea is when sapi string turn back:
0 - result to be inactive
1 or other kind of number - active
if is turn back nothing - to give unknown status
Upvotes: 0
Views: 34
Reputation: 41460
You can use case
. Here is an example from some of my older posts.
#! /bin/bash
case "$(ps -ef | awk '/[w]eblogic/ && /sapi/ {a++} END {print a+0}')" in
0) echo "0 found"
;;
1) echo "1 found"
;;
*) echo "more than 1 found"
;;
esac
I did also simplified your test some.
PS you should not use old and outdated back-tiks, use parentheses var=$(awk 'some code')
Upvotes: 1