Need help writing a unix script

Posted on 2006-03-23
Last Modified: 2013-12-26
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

Thanks, Hope you can help
Question by:AndreKelly
    LVL 43

    Accepted Solution

    > 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?


    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
    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
    LVL 51

    Assisted Solution

    egrep '(Dialing failed, modem dialing error|Status: \[11\] Deactivate, Port Exited)' /opt/pg/telalert.trail && CMSG

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Get filename and folder into excel 7 63
    iSeries FTP Exit Program 8 99
    if loop in java 3 99
    string initialization in java 11 94
    Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
    If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now