0

looking for your advise.. i have expect script which execute perfectly and save output to a file, filename is 'fileout'.. output from fileout shows like below..

 NAME                               STATE            
--------------------------------------------------------------------
Data Listener                      not running
DB Server                          not running
EST Service                         running
Profiler                           not running
Indexing Engine                    disabled
AD Listener                        not running

I am trying to use script..condition is.. if EST service state show any other state other than running then it should send mail and if not then keep continue running at define interval(10min)..i am using nohup for this but it looks there is some problem in my script to match such condition so looking for you advise.

tail -f fileout | stdbuf -oL grep not running | mailx -s "notification" -r "[email protected]" "[email protected]"
1
  • i tried tail -f but it looks hanging and mail dont sent out, how can we terminate when tail -f finish its job
    – anukalps
    Sep 24, 2022 at 18:53

1 Answer 1

1

If you only want to perform an action for the EST Service then you can grep for that specifically.

tail -f fileout | stdbuf -oL grep "not running" | grep "EST Service" | xargs -l -i mailx -s {} -r "[email protected]" "[email protected]"
1
  • Hi..but where does it show that mail will be sent only if EST Service state is not running not other, i am looking if there is any other state other than running for EST Service then mail should be sent.
    – anukalps
    Sep 23, 2022 at 18:07

Not the answer you're looking for? Browse other questions tagged .