Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error/return code of awk script

Status
Not open for further replies.

Baraka69

Programmer
Apr 22, 2003
32
DE
I have an AWK script that has to plow through an access_log (apache web server) and I have a surfer/user (lucky for me he has a fixed ip-address) that produces lines that are longer than 3,000 bytes/characters and then my awk script quits with an error message (don't have the exact wording, but can supply it, if it is necessary).

I can get rid of the lines that are too long using SED, but for now I have to do it all manually.

I want to have a shell script to call (and run) my awk script. If the awk script fails because the input file contains lines that are too long, it should (but only in this case) run my SED script and afterwards run the AWK script again.

My question is: how do I read the exit code of my AWK script? Is there an exit code? My guess is that there might be an exit code greater ZERO if an error occurs.

Anyone know for sure?
 
I believe that's been answered in another forum.

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Quite right. I found the UNIX Forum and posted a similar question there. An answer got me going and now I am a lot further into this matter.

My particular question here was what are the AWK exit codes?

For my example I found out that the exit code is &quot;2&quot;.
The error Message displayed was:
&quot;awk: Input line LINEDATA cannot be longer than 3,000 bytes.&quot;

I failed to find any information on exit codes (I have some good print/web sources, but they come up empty, apart from the &quot;exit&quot; statement).
 
here's the excerp from nawk's man page:

EXIT STATUS
The following exit values are returned:

0 All input files were processed successfully.

>0 An error occurred.

The exit status can be altered within the program by using
an exit expression.


vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top