• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 267
  • Last Modified:

Need help writing a unix script

I am a beginning scripter and I need help writing a unix script that will look inside a file match on exact wording then

send an alert .(we use something called CMSG for the alert part via TELALERT)


File location:  /opt/pg/telalert.trail

Text to match inside telalert.trail  :   Dialing failed, modem dialing error
                                                    Status: [11] Deactivate, Port Exited

The previous are 2 separate error messages

Also do I need the variable definitions:   PATH
                                                          REF
                                                          SPATH1
                                                          OUTLOG

Thanks, Hope you can help
0
AndreKelly
Asked:
AndreKelly
2 Solutions
 
ravenplCommented:
> Also do I need the variable definitions:
What You mean, You want to set them(I assumed) or send it's content along with warning?

#!/bin/sh

export PATH="/new/directory:$PATH" # preserves old PATHs as well
# same way You may set rest of them

grep -q "Dialing failed, modem dialing error" /opt/pg/telalert.trail
RET1=$?
grep -q "Status: [11] Deactivate, Port Exited" /opt/pg/telalert.trail
if [ $$RET1 -ne 0 -o $? -ne 0 ]; then
 #send our warning, call CMSG or watever. What is it's syntax?
 # here example for mail sending
 echo -e "Search for error strings succeded\nPATH content: $PATH\nREF content: $REF" | mail -s "mail subject" destination@domain.tld
fi
0
 
ahoffmannCommented:
egrep '(Dialing failed, modem dialing error|Status: \[11\] Deactivate, Port Exited)' /opt/pg/telalert.trail && CMSG
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now