Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Parsing output with awk - need assistance on exception Post 303004135 by SIMMS7400 on Wednesday 27th of September 2017 03:44:36 AM
Old 09-27-2017
Wow - thank you, Don! This is working like a charm!

I do have one additional piece I want to add. On the "3rd" loop, I need to put a piece of email functionality in there.

Something like this:

Code:
if [ $run = "3" ]; then
    #echo "Active EAS session(s) still in progress on $essb_app - session(s) have been active for 30 minutes.  Script will continue to loop for 2 more times." | mail -s "MS_DIR Refresh Unable to Run" joesmith@email.com
    echo "Active EAS session(s) still in progress on $essb_app - session(s) have been active for 30 minutes.  Script will continue to loop for 2 more times."
    echo    
fi

I'm not sure how to incorporate it though - is this possible?

Thanks you!

---------- Post updated at 03:44 AM ---------- Previous update was at 03:32 AM ----------

Hi Don -

I've added it as follows and it's working as expected:

Code:
TEMPFILE=$ms_logs/tempout.txt

CheckSessions() {
    for run in {1..5}
    do
        [ $run -gt 1 ] && sleep 5
        
        [ -e "$_MAXLLOGFILE" ] && rm "$_MAXLLOGFILE"

        . "$_STARTMAXL_PATH"startMaxl.sh \
            "$_MAXLSCRIPTPATH"Display_Sessions.mxl "$_ESSB_USER" \
            "$_ESSB_PSWD" "$_ESSB_SRVR" "$_ESSB_APP" "$_ESSB_DB" \
            "$_MAXLLOGFILE"

        if awk '
            {for(i = 5; i <= NF - 2; i++)
                if($i == "MS_DIR" && $(i + 2) != "none") {
                    rc = 1
                    print $(i + 2)
                }
            }
            END {    exit rc
            }' "$_MAXLLOGFILE" > "$TEMPFILE"
        then
            echo "Attention! No active EAS sessions detected on $essb_app"
            echo "Returning to main script body to proceed"
            rm "$TEMPFILE"
            return 0
        fi
        
    if [ $run = "3" ]; then
    echo $run
    #echo "Active EAS session(s) still in progress on $essb_app - session(s) have been active for 30 minutes.  Script will continue to loop for 2 more times." | mail -s "MS_DIR Refresh Unable to Run" joesmith@email.com
    echo "Active EAS session(s) still in progress on $essb_app - session(s) have been active for 30 minutes.  Script will continue to loop for 2 more times."
    echo    
    fi
    
    done
    
    echo $run
    echo "Active EAS requests still in-progress:"
    echo
    cat "$TEMPFILE"
    echo
    echo "Unable to proceed with script execution"
    echo
    rm "$TEMPFILE"
    return 1
}

#::-- Begin Script Processing --::#

echo ---------------------------------------------------------
echo "${_SN} beginning at ${_TIME}"                           
echo ---------------------------------------------------------

echo ---------------------------------------------------------                                                                                                
echo "Execute Function to determine Essbase Active Sessions"                                         
echo ---------------------------------------------------------

CheckSessions

_RVAL=$?

if [ $_RVAL -eq 0 ]
then
    echo ---------------------------------------------------------
    echo "Function Result : Successful"                           
    echo ---------------------------------------------------------
  
else
    echo ---------------------------------------------------------
    echo "Function Result : Unsuccessful"                      
    echo ---------------------------------------------------------
    # put email piece here
    exit 1
fi

Please let me know if that is incorrect - thank you!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script Assistance - Outputting to file with Awk

I'm trying to take a list of domains, find out the MX resolve it to IP then find out what the NS is and output the contents to a new file. The only problem i'm having is when checking the Ip or host of the MX i can only get it to print the column with the MX record and the results of the host... (1 Reply)
Discussion started by: spartan22
1 Replies

2. Shell Programming and Scripting

AWK statement formatting assistance

I am writing a script that ssh's out to our various servers and extracts diskspace info to generate into a report. With the mix of servers linux/solairs 8-10/AIX the easiest way is to use df -k (though I much rather prefer df -h). I have pasted the relevant code: dfdata=`ssh -q -o... (1 Reply)
Discussion started by: rkruck
1 Replies

3. Shell Programming and Scripting

Awk Assistance

Hello A friend of mine posted this on another site that I follow. It is to advanced for me to figure out. If solved I will give credit where credit is due: NOTE: Does not have to be AWK. Any Language will work, Hi. I need a little assistant to write an awk script on linux that reads a file... (12 Replies)
Discussion started by: abacus
12 Replies

4. UNIX for Dummies Questions & Answers

awk o/p assistance

Hi, I would like to know the awk command that gets the below o/p: File contents: Board1;9a;60;36;60.0;60;0;0.0 Board2;96;60;35;58.3;55;0;0.0 Board3;92;60;60;100.0;60;60;100.0 Used awk script: #!/bin/awk -f BEGIN { FS = ";"; printf (" Device | ... (1 Reply)
Discussion started by: Dendany83
1 Replies

5. Shell Programming and Scripting

Awk - Script assistance on identifying non matching fields

Hoping for some assistance. my source file consists of: os, ip, username win7, 123.56.78, john win7, 123.56.78, paul win7, 10.1.1.1, john win7, 10.2.2.3, joe I've been trying to run a script that will only return ip and username where the IP address is the same and the username is... (3 Replies)
Discussion started by: tekvaio
3 Replies

6. Shell Programming and Scripting

Re: exception using AWK

I have following file: NAME=ora.DG1.svc TYPE=ora.service.type CARDINALITY_ID=1 TARGET=ONLINE STATE=ONLINE NAME=ora.orlene.DG2.svc TYPE=ora.service.type CARDINALITY_ID=1 TARGET=ONLINE STATE=OFFLINE NAME=ora.MN.acfs TYPE=ora.registry.acfs.type TARGET=ONLINE (4 Replies)
Discussion started by: rcc50886
4 Replies

7. Shell Programming and Scripting

Monitor logs for exception and if exception come then sent an email

Hi Folks, please advise , I have logs generated on unix machine at location /ops/opt/aaa/bvg.log , now sometimes there come exception in these logs also, so I want to write such a script such that it should continuously monitor these logs and whenever any exception comes that is it try to find... (3 Replies)
Discussion started by: tuntun27272727
3 Replies

8. Shell Programming and Scripting

Assistance with an awk code to split files but keep the header

---------- Post updated at 11:48 AM ---------- Previous update was at 11:46 AM ---------- Hello all I have an awk code that successfully creates separate text files based on the first six letters of the second field. What it doesn't do is preserve the header into each resulting file. ... (6 Replies)
Discussion started by: colecandoo
6 Replies

9. Shell Programming and Scripting

Assistance required with awk and regular expressions

Hello there, I am trying to get my head around the section below of a script we use that incorporates AWK and Regular Expressions. { match($0,"The broker*");print $1,$2,$3 ":", substr($0, RSTART,RLENGTH)} I have a basic understanding of how match works, what I am struggling with is the... (2 Replies)
Discussion started by: jimbojames
2 Replies

10. UNIX for Beginners Questions & Answers

awk assistance - Comparing 2 csv files

Hello all, I have searched high and low for a solution to this, many have come really close but not quite what I'm after. I have 2 files. One contains GUID's, for example: 8121E002-96FE-4C9C-BC5A-6AFF20DACECD 84468F30-F3B7-418B-81F0-0908E80792BF A second file, contains a path to the... (8 Replies)
Discussion started by: tirmUK
8 Replies
All times are GMT -4. The time now is 09:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy