![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages 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 | 2 | 05-06-2009 08:04 AM |
| Installing RedHat 8.0 onto Dell PowerEdge SC1425 - hdc: status error: status = 0x58 | fishsponge | Red Hat | 5 | 07-14-2006 02:53 PM |
| awk to find the status and send an email | isingh786 | UNIX for Dummies Questions & Answers | 6 | 12-21-2005 10:12 PM |
| Ftp Status Check | acheepi | Shell Programming and Scripting | 4 | 09-08-2005 03:23 PM |
| Couldn't open status file /var/samba/STATUS.LCK | macdonto | UNIX for Dummies Questions & Answers | 2 | 08-08-2001 08:42 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
|
|||||
|
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 |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|