syntax error

This is a discussion on syntax error within the awk forums in Programming Languages category; # awk 'BEGIN {min=9999999} $NF > max {max=$NF; maxline=$0}; $NF < min {min=$NF; minline=$0} END {print max, maxline "\n" min, minline}' access.log 3190709 192.168.1.200 - - [07/Jul/2008:15:53:38 +0000] "GET /700.xml HTTP/1.0" 200 24634 3190709 193 192.168.1.200 - - [06/Jul/2008:21:25:40 +0000] "GET /audio/vm/ Numbers%20(0).wav HTTP/1.0" 304 - 193 # cat tt.awk function cvttime(t, a) { split(t,a,"[/:]") match("JanFebMarAprMayJunJulAugSepOctNovDec",a[2]) a[2] = sprintf("%02d",(RSTART+2)/3) return( mktime(a[3]" "a[2]" "a[1]" "a[4]" "a[5]" "a[6]) ) } BEGIN { now=systime(); tgt=300; mintime=99999999 } { then=cvttime(gensub(/.*\[(.*)\].*/,"\\1","")) } { if ((now - then) < tgt) { $NF > maxtime {maxtime=$NF; maxline=$0}; $NF < mintime {mintime=$NF; minline=$0}; hits++; sumtime+=$NF; th=then } else ...

Go Back   Application Development Forum > Programming Languages > awk

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 07-07-2008, 06:47 PM
dnlchen@gmail.com
Guest
 
Default syntax error

# awk 'BEGIN {min=9999999} $NF > max {max=$NF; maxline=$0}; $NF < min
{min=$NF; minline=$0} END {print max, maxline "\n" min, minline}'
access.log
3190709 192.168.1.200 - - [07/Jul/2008:15:53:38 +0000] "GET /700.xml
HTTP/1.0" 200 24634 3190709
193 192.168.1.200 - - [06/Jul/2008:21:25:40 +0000] "GET /audio/vm/
Numbers%20(0).wav HTTP/1.0" 304 - 193

# cat tt.awk
function cvttime(t, a) {
split(t,a,"[/:]")
match("JanFebMarAprMayJunJulAugSepOctNovDec",a[2])
a[2] = sprintf("%02d",(RSTART+2)/3)
return( mktime(a[3]" "a[2]" "a[1]" "a[4]" "a[5]" "a[6]) )
}
BEGIN { now=systime(); tgt=300; mintime=99999999 }
{ then=cvttime(gensub(/.*\[(.*)\].*/,"\\1","")) }
{ if ((now - then) < tgt) { $NF > maxtime {maxtime=$NF; maxline=$0};
$NF < mintime {mintime=$NF; minline=$0}; hits++; sumtime+=$NF;
th=then }
else {exit} }
END { print "sumtime="sumtime, "hits="hits, "maxtime="maxtime,
"mintime="mintime "\n" maxline "\n" minline "\n" }

# tac access.log | awk -f tt.awk
awk: tt.awk:9: { if ((now - then) < tgt) { $NF > maxtime {maxtime=$NF;
maxline=$0}; $NF < mintime {mintime=$NF; minline=$0}; hits++; sumtime+=
$NF; th=then }
awk: tt.awk:9: ^ syntax
error
awk: tt.awk:9: { if ((now - then) < tgt) { $NF > maxtime {maxtime=$NF;
maxline=$0}; $NF < mintime {mintime=$NF; minline=$0}; hits++; sumtime+=
$NF; th=then }
awk: tt.awk:
9:
^ syntax error

Reply With Quote
  #2  
Old 07-08-2008, 01:02 PM
dnlchen@gmail.com
Guest
 
Default Re: syntax error

On Jul 7, 3:47*pm, dnlc...@gmail.com wrote:
> # awk 'BEGIN {min=9999999} $NF > max {max=$NF; maxline=$0}; $NF < min
> {min=$NF; minline=$0} END {print max, maxline "\n" min, minline}'
> access.log
> 3190709 192.168.1.200 - - [07/Jul/2008:15:53:38 +0000] "GET /700.xml
> HTTP/1.0" 200 24634 3190709
> 193 192.168.1.200 - - [06/Jul/2008:21:25:40 +0000] "GET /audio/vm/
> Numbers%20(0).wav HTTP/1.0" 304 - 193
>
> # cat tt.awk
> function cvttime(t, * * a) {
> * * * * split(t,a,"[/:]")
> * * * * match("JanFebMarAprMayJunJulAugSepOctNovDec",a[2])
> * * * * a[2] = sprintf("%02d",(RSTART+2)/3)
> * * * * return( mktime(a[3]" "a[2]" "a[1]" "a[4]" "a[5]" "a[6]) )}
>
> BEGIN { now=systime(); tgt=300; mintime=99999999 }
> { then=cvttime(gensub(/.*\[(.*)\].*/,"\\1","")) }
> { if ((now - then) < tgt) { $NF > maxtime {maxtime=$NF; maxline=$0};
> $NF < mintime {mintime=$NF; minline=$0}; hits++; sumtime+=$NF;
> th=then }
> * else {exit} }
> END { print "sumtime="sumtime, "hits="hits, "maxtime="maxtime,
> "mintime="mintime "\n" maxline "\n" minline "\n" }
>
> # tac access.log | awk -f tt.awk
> awk: tt.awk:9: { if ((now - then) < tgt) { $NF > maxtime {maxtime=$NF;
> maxline=$0}; $NF < mintime {mintime=$NF; minline=$0}; hits++; sumtime+=
> $NF; th=then }
> awk: tt.awk:9: * * * * * * * * * * * * * * * * * * * * * ^ syntax
> error
> awk: tt.awk:9: { if ((now - then) < tgt) { $NF > maxtime {maxtime=$NF;
> maxline=$0}; $NF < mintime {mintime=$NF; minline=$0}; hits++; sumtime+=
> $NF; th=then }
> awk: tt.awk:
> 9:
> ^ syntax error


I think there was a problem of posting yesterday, so this message
appears two times. Can someone delete one? sorry for that.
Reply With Quote
  #3  
Old 07-08-2008, 01:38 PM
loki harfagr
Guest
 
Default Re: syntax error

On Tue, 08 Jul 2008 10:02:36 -0700, dnlchen wrote:

>> 9:
>> ^ syntax error

>
> I think there was a problem of posting yesterday, so this message
> appears two times. Can someone delete one? sorry for that.


hem, are you by any bad luck chance posting from GooGroobs and
believed the propaganda they use as a supposedly "help caption"
"Create mailing lists and discussion groups"

This is not a mailing list, this is Usenet groups,
this is not a "discussion group" like an IRC (or chat)
parlour, this is an unmoderated Usenet group and what
you post is here to stay (at least as long as the GG
and the govs looneys won't have it as stone cold dead
as the prick of a spammer).

--
stop this right now, there's no fish in here.
- Ice Rink Manager
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 03:49 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.