The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Check FTP Status april Shell Programming and Scripting 1 08-03-2007 08:22 PM
Installing RedHat 8.0 onto Dell PowerEdge SC1425 - hdc: status error: status = 0x58 fishsponge Linux 5 07-14-2006 11:53 AM
awk to find the status and send an email isingh786 UNIX for Dummies Questions & Answers 6 12-21-2005 07:12 PM
Ftp Status Check acheepi Shell Programming and Scripting 4 09-08-2005 12:23 PM
Couldn't open status file /var/samba/STATUS.LCK macdonto UNIX for Dummies Questions & Answers 2 08-08-2001 05:42 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-29-2005
Registered User
 

Join Date: Aug 2005
Posts: 75
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
AK9~A~2~2~2
SE~8~0001
GE~1~000011258
IEA~00001~000011258

ISA~00~ ~00~ ~ZZ~F159B ~ZZ~U1CAD ~051227~191
3~U~00200~000011467~0~P~<
GS~FA~AF52M~U1CAD~051227~1913~000011467~X~002002
ST~997~0001
AK1~SH~53
AK2~856~530001
AK5~A
AK9~A~1~1~1
SE~6~0001

The data I am looking for is in the first line that starts with ISA and the third column data is “~ZZ~F159B” and “~ZZ~VISTN”.

On the basis of the above mentioned segments, I have to assign them status either as pass or fail, which has been accomplished by the code snippet provided by Vgersh99 and Rancha.

grep "~ZZ~" <data file> | nawk '{ print ($3=="~ZZ~VISTN") ? "passed":"failed" }'

Now the new requirement is that I have to send an email, which should have the status in the body of the email. Can this be achieved in one script or I have to write two scripts like one has the static body of the email and it just expects two arguments.

Template for static email:

Please be advised that the EDI ASN has been “status” (either passed or failed).

Hope this is not too confusing.

Regards,
Inder
Reply With Quote
Forum Sponsor
  #2  
Old 12-29-2005
linuxpenguin's Avatar
Registered User
 

Join Date: May 2002
Location: India
Posts: 295
grep "~ZZ~" dat.txt | nawk '{ print ($3=="~ZZ~VISTN") ? "Please be advised that
the EDI ASN has been passed":"Please be advised that the EDI ASN has been failed
" }'



or in general

grep "~ZZ~" dat.txt| awk '{
if ( $3 == "~ZZ~VISTN" ) {
print "huge msg with status passed"
}
else
print "another message with status failed"
}'
__________________
War doesnt determine who is right, it determines who is left
Reply With Quote
  #3  
Old 12-29-2005
Registered User
 

Join Date: Aug 2005
Posts: 75
Hi,

Thanks a lot!!!

It works like a treat!!

Is it possible to re-direct this message to some file or send an email?

Regards,
Inder
Reply With Quote
  #4  
Old 12-29-2005
linuxpenguin's Avatar
Registered User
 

Join Date: May 2002
Location: India
Posts: 295
To email the message=

grep "~ZZ~" dat.txt| awk '{
if ( $3 == "~ZZ~VISTN" ) {
print "huge msg with status passed"
}
else
print "another message with status failed"
}' | mail urid@whatever.com

or
to redirect it to some file

grep "~ZZ~" dat.txt| awk '{
if ( $3 == "~ZZ~VISTN" ) {
print "huge msg with status passed"
}
else
print "another message with status failed"
}' > redirect_file_name
__________________
War doesnt determine who is right, it determines who is left
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:08 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0