![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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 |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
||||
|
||||
|
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 |
||||
| Google The UNIX and Linux Forums |