Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have written a script to awk a file, which beings with STATUS_MESSAGE and read a parameter $STCODE. It should read the second column in the text file i.e. ^1$ and if it meets the condition read the message “See BOA-NBU-1. Partial success”. But I am finding that I am getting an awk failure. Can someone offer some advice!!
AWK COMMAND
=============# `awk < nberrors_rules.txt '/^STATUS_MESSAGE / && '$STCODE' ~ $2 '`
awk: syntax error near line 1
awk: bailing out near line 1TEXT FILE - nberrors_rules.txt
========================STATUS_MESSAGE ^1$ See BOA-NBU-1. Partial success.
STATUS_MESSAGE ^(56|58)$ See BOA-NBU-2. Network problems.
.........King Regards
Junes

If i try the -f option for awk, i get the "awk: can't open " error message
The following awk statement works fine without the -f option
`awk <$RULES '/^IGNORE_POLICY / { print $2 }'`Below how i turned on debugging to show what is happening, can someone provide me with some advice!!!!
$RULES = /home/nberrors_rules_jm_NEW.txt_TEST
$2 = ^219$ of the following (STATUS_MESSAGE ^219$ See BOA-NBU-1. Partial success)
MESSAGE=`awk <$RULES '/^STATUS_MESSAGE / && '$STCODE' ~ $2 { for(a=3;a<NF+1;a++) { printf "%s ",$a }}'`
...........
+ + awk /^STATUS_MESSAGE / && 219 ~ $2 { for(a=3;a<NF+1;a++) { printf "%s ",$a }}
+ 0< /home/nberrors_rules_jm_NEW.txt_TEST
awk: syntax error near line 1
awk: bailing out near line 1
MESSAGE=
STCODE_POL_MESSAGE=`awk <$RULES '/^STATUS_MESSAGE_POLICY / && '$STCODE' ~ $2 && toupper("'$POLICY'") ~ toupper($3) { for(a=4;a<NF+1;a++) { printf "%s ",$a }}'`
...........
+ + awk /^STATUS_MESSAGE_POLICY / && 219 ~ $2 && toupper("emacromsq14") ~ toupper($3) { for(a=4;a<NF+1;a++) { printf "%s ",$a }}
+ 0< /home/nberrors_rules_jm_NEW.txt_TEST
awk: syntax error near line 1
awk: bailing out near line 1
STCODE_POL_MESSAGE=
King RegardsJunes

![]() |
sed scripting question
|
sed to find and add lines
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |