Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


error/return code of awk script

error/return code of awk script

error/return code of awk script

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?

RE: error/return code of awk script

I believe that's been answered in another forum.

| #include<disclaimer.h> |

RE: error/return code of awk script

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 "2".
The error Message displayed was:
"awk: Input line LINEDATA cannot be longer than 3,000 bytes."

I failed to find any information on exit codes (I have some good print/web sources, but they come up empty, apart from the "exit" statement).

RE: error/return code of awk script

here's the excerp from nawk's man page:

     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.

| #include<disclaimer.h> |

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close