awk to find the status and send an email


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers awk to find the status and send an email
# 1  
Old 12-16-2005
check the status and send an email

Hi,

I have a datafile which has the following data and it can have much more records. The data set is as follows:

ISA~00~ ~00~ ~ZZ~F159B ~ZZ~U1CAD ~051215~184
3~U~00200~000011432~0~P~<
GS~FA~TC11A~U1CAD~051215~1843~000011432~X~002002
ST~997~0001
AK1~SH~1168
AK2~856~11680001
AK5~A
AK9~A~1~1~1
SE~6~0001
GE~1~000011432
IEA~00001~000011432

The name of the file is 997.lst. What I have to do is the grep AK5 and AK9 segments line 7 & 8 and
(AK5~A AK9~A~1~1~1) if they have A then sent am email with success otherwise un-successful.

I would really apprecitate if somebody has any code snippet similar to this.

TIA,
Inder
# 2  
Old 12-19-2005
Hi,

Does anybody have a code snippet like this?

Regards,
# 3  
Old 12-19-2005
awk -F ~ '{
if ( ( $1 == "AK5" || $1 == "AK9" ) && ( $2 == "A" ) ) {
your_mail_program_or_script
}
}' filename
# 4  
Old 12-21-2005
Hi,

Thanks for the reply!!

I did not understand like where I have to give the filename which has the contents, which I want to compare with:

awk -F ~ '{
if ( ( $1 == "AK5" || $1 == "AK9" ) && ( $2 == "A" ) ) {
your_mail_program_or_script
}
}' filename

I have the file mail_997.lst which has the contents AK5 and Ak9 which I want to compare using this script. So should I use the mail_997.lst instead of filename. Please confirm.
# 5  
Old 12-21-2005
awk to find the status and send an email

Hi,

I have a file named mail_997.lst which has the following contents:

ISA~00~ ~00~ ~ZZ~F159B ~ZZ~U1CAD ~051206~171
3~U~00200~000011405~0~P~<
GS~FA~TC12A~U1CAD~051206~1713~000011405~X~002002
ST~997~0001
AK1~SH~1115
AK2~856~11150001
AK5~A
AK9~A~1~1~1
SE~6~0001
GE~1~000011405
IEA~00001~000011405
ISA~00~ ~00~ ~ZZ~VISTN ~ZZ~U1CAD ~051206~210
3~U~00200~000011198~0~P~<

In the data, we have different segments like AK5 and AK9, I have to write a code snippet where it greps this file look for AK5 and Ak9 segments and if it has a "A" then send an email saying successful otherwise un-successful.

AK5~A
AK9~A~1~1~1
# 6  
Old 12-21-2005
Maybe something like this:

Code:
nawk -F'~' '$1 ~ /AK[59]/ {
    status=($2=="A") ? "successful" : "unsuccessful"
    system ("mailx -s" $1 ":\\ " status "\ recipient@email_domain.com </dev/null")
}' yourdatafile

This User Gave Thanks to tmarikle For This Post:
# 7  
Old 12-21-2005
Threads merged.

Please do not cross-post.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To get older than last 7days records using awk scripting to generate report and send email

Hello All, I have need as below: 1--> I need to get all users(who submit jobs) and their details by using below command: qstat -u \* output of the above command looks line below: job-ID prior name user-id state "submit/start at" queue jclass slots ja-task-ID... (5 Replies)
Discussion started by: VasuKukkapalli
5 Replies

2. Shell Programming and Scripting

Send Disk Space Usage Status via email

Hi Guys, Is there any way I can write a script that sends DISK SPACE USAGE STATUS via email once a week? Thanks, (5 Replies)
Discussion started by: g4v1n
5 Replies

3. Shell Programming and Scripting

Loop multiple directory, find a file and send email

Hello ALL, need a BASH script who find file and send email with attachment. I have 50 folders without sub directories in each generated files of different sizes but with a similar name Rp01.txt Rp02.txt Rp03.txt ...etc. Each directors bound by mail group, I need a script that goes as... (1 Reply)
Discussion started by: penchev
1 Replies

4. SuSE

Send outgoing email to my GroupWise email

Dear users, I have Linux server whose versions are Suse 10 SP 3 and Suse 11. I am trying to send email from these servers to my GroupWise email account. In /etc/postfix/main.cf file, The current value of MYHOSTNAME is LINUX.LOCAL. What should be the right value of MYHOSTNAME? Is... (0 Replies)
Discussion started by: JDBA
0 Replies

5. Shell Programming and Scripting

Help....script check status if see something then send email

autorep -m bogus Machine Name Max Load Current Load Factor O/S Status ___________ ________ ___________ ______ ________ ______ bogus --- --- 1.00 Sys Agent Online Status ______ Online Offline Missing Unqualified The "Status" always "Online". I like create a script execute run... (6 Replies)
Discussion started by: dotran
6 Replies

6. UNIX for Dummies Questions & Answers

new to ldap, send email to a ou or group, and see a list from email client

hi, i'm running openldap on ubuntu 10.04, creating new items with apache directory studio (windows version). i use the ldap just as an address book to our small office (email clients are windows live mail 2009, 2011, microsoft outlook 2007 and 2010). a. i cant see a list of the contacts,... (0 Replies)
Discussion started by: V4705
0 Replies

7. Shell Programming and Scripting

Script to send email after comparing the folder permissions to a certain permission & send email

Hello , I am trying to write a unix shell script to compare folder permission to say drwxr-x-wx and then send an email to my id in case the folders don't have the drwxr-x-wx permissions set for them . I have been trying to come up with a script for few days now , pls help me:( (2 Replies)
Discussion started by: nairshar
2 Replies

8. Solaris

Send an email from Solaris using Linux email server

Hello everyone I have a problem and I need your help: I have a Solaris 10 and Solaris 8 UNIX Servers, and Linux Centos4 as email server. I need send an email from Solaris servers preferably using Centos4 email server. I have no mail service configured in my Solaris computers (1 Reply)
Discussion started by: aflores
1 Replies

9. Shell Programming and Scripting

check the status and send an email with status

Hi, We have a text file which has the following data. ISA~00~ ~00~ ~ZZ~VISTN ~ZZ~U1CAD ~051227~183 7~U~00200~000011258~0~P~< GS~FA~EE05J~U1CAD~051227~1831~000011258~X~002002 ST~997~0001 AK1~SH~247 AK2~856~2470001 AK5~A AK2~856~2470002 AK5~A... (3 Replies)
Discussion started by: isingh786
3 Replies

10. UNIX for Advanced & Expert Users

Unable to send eMail from a UNIX-Host ( using mailx ) to a Outlook-email-addres(Win)

Hi A) I am able to send eMail using mailx from a UNIX ( solaris 8 ) host to my Outlook-email-ID : FName.Surname@Citigroup.com ( This is NOT my actual -eMail-ID). But in Outlook the "From :" eMail address is displayed as " usr1@unix-host1.unregistered.email.citicorp.com " .i.e the words... (2 Replies)
Discussion started by: Vetrivela
2 Replies
Login or Register to Ask a Question