Link to home
Start Free TrialLog in
Avatar of brothertom
brothertom

asked on

Bash script to check a process output, then do something

Hi,

Looking for a script to do the following - start the program is its status is not running.
The program returns the string 'not running' if not running, else some other text :

status = /home/user/program getstatus
if (status == 'not running') {
  /home/user/program start
} else {
 // do nothing
}

Can someone help out please.

Thanks
BT
ASKER CERTIFIED SOLUTION
Avatar of farzanj
farzanj
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tintin
Tintin

As a one liner


[ "$(/home/user/program getstatus)" = 'not running' ] && /home/user/program start

Open in new window

Avatar of brothertom

ASKER

Many thanks - worked nicely :)