Welcome to the Linux Foundation Forum!

Flow control based on grep match pattern or string

Hi,

Looking to create a flow control based on a string or pattern matched in a log file.

The log file may contain either of these

1 CONFSUCCESS

2 CONFFAIL

3 CONFPARTIAL

Example:

cat System.log

dsfasdfasfas

adfsfasfa

safafaf sdfaasfsa CONFSUCCESS

adsfasdfadsfadsf fafasfasdfasdf fafasfafsa

sadfafasfasdfadss fdsafadff fasfadfaf asff

So idea is to grep the message from log, based on pattern run a flow control as below.

if

1 Look in System.log - CONFSUCCESS - show message as - SUCCESSFUL - Ask user to - Press ENTER to continue

if

2 Look in System.log - CONFFAIL - show message as - FAILURE - Exit (come out of shell)

if

3 Look in System.log - CONFPARTIAL - Show message as - PARTIALSUCCESS - Exit (come out of shell)

Thanks

Sign In or Register to comment.