This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
Re: awk script compile problem
- To: hrishy <hrishys at yahoo dot co dot uk>
- Subject: Re: awk script compile problem
- From: Keith Seitz <keiths at cygnus dot com>
- Date: Tue, 4 Sep 2001 07:57:08 -0700 (PDT)
- cc: <cygwin at cygwin dot com>
On Tue, 4 Sep 2001, [iso-8859-1] hrishy wrote:
> a few minutes ago i installed cygwin and i tried to
> run the following program.
I doubt very much that this worked on anything. This awk program clearly
has an obvious syntax error. On RH7.0:
keiths ~ >awk -f a.awk
awk: a.awk:10: if (( $2 ~ /Label/ ) && ( $3 ~ /Not found/ )) {
awk: a.awk:10: ^ parse error
awk: a.awk:13: if (( $2 ~ /Form/ ) && ( $3 ~ /Not found/ )) {
awk: a.awk:13: ^ parse error
awk: a.awk:16: if (( $2 ~ /Report/ ) && ( $3 ~ /Not found/ )){
awk: a.awk:16: ^ parse error
I also get similar errors on Solaris using its standard awk:
keiths ~ >/usr/bin/awk -f a.awk
awk: syntax error near line 10
awk: bailing out near line 10
The structure of an awk program looks like ("..." = statements):
[BEGIN] { ... }
{ ... }
[END] { ... }
Not like what you have:
{ ... }
...
END { ... }
Add braces ("{","}") at the appropriate places and it will work just fine.
> #BEGIN
> {
> FS="|"
> }
Add "{" here.
> if (( $2 ~ /Label/ ) && ( $3 ~ /Not found/ )) {
> label=label+1
> }
> if (( $2 ~ /Form/ ) && ( $3 ~ /Not found/ )) {
> form=form+1
> }
> if (( $2 ~ /Report/ ) && ( $3 ~ /Not found/ )){
> report=report+1
> }
Add "}" here.
> END { print FILENAME, "\t" label "\t"form "\t" report
> >>"result.log"}
>
> this program runs correctly under mkstoolkit and on my
> linux box.but fails to under cygwin.
>
> with a parse error ^ if (( $2 ~ /Report/ ) && ( $3
> ~ /Not found/ )){
Keith
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/