Thread View: gnu.utils.bug
1 messages
1 total messages
Started by Frank Wortner
Mon, 16 Jan 1989 19:49
GAWK 2.00 Beta Bug
Author: Frank Wortner
Date: Mon, 16 Jan 1989 19:49
Date: Mon, 16 Jan 1989 19:49
186 lines
5454 bytes
5454 bytes
GAWK 2.00 will not run the program in the shar file below. I've enclosed
a short sample data file.
Here is a sample session on a Sun 3/110 running SunOS 4.O.
Script started on Mon Jan 16 14:43:18 1989
hudson% /bin/awk -f syslog_awk SYSLOG
System Xfers Bytes rec Bytes xmt Connect Avg Xf Avg rec Avg xmt
phri 2 12532 0 0:01:01 6266 205 0
TOTALS 2 12532 0 0:01:01
hudson%
hudson%
hudson%
hudson% gawk -f syslog_awk SYSLOG
gawk: syntax error near line 10:
sys_xf[$2] ++;
^ parse error
hudson%
hudson%
hudson%
script done on Mon Jan 16 14:44:12 1989
----------------------------Cut Here-----------------------------------------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# syslog_awk
# SYSLOG
# This archive created: Mon Jan 16 14:32:20 1989
export PATH; PATH=/bin:$PATH
echo shar: extracting "'syslog_awk'" '(2728 characters)'
if test -f 'syslog_awk'
then
echo shar: will not over-write existing file "'syslog_awk'"
else
sed 's/^ X//' << \SHAR_EOF > 'syslog_awk'
X# USAGE: awk -f syslog_awk /usr/spool/uucp/SYSLOG
X# An awk script for printing a pretty report of UUCP activities from the
X# UUCP SYSLOG - Erik E. Fair October 2, 1984
X#
X# v7 UUCP
X$4 == "received" {
X sysname[$2] = $2;
X by_rec[$2] += $6;
X sec_rec[$2] += $8;
X sys_xf[$2] ++;
X}
X#
X# 4.2 BSD UUCP
X$5 == "received" {
X sysname[$2] = $2;
X by_rec[$2] += $7;
X sec_rec[$2] += $9;
X sys_xf[$2] ++;
X}
X#
X# System V UUCP
X$6 == "<-" {
X $1 = substr($1, 1, (index($1, "!") - 1));
X sysname[$1] = $1;
X by_rec[$1] += $7;
X sec_rec[$1] += $9;
X sys_xf[$1] ++;
X}
X#
X# v7 UUCP
X$4 == "sent" {
X sysname[$2] = $2;
X by_xmt[$2] += $6;
X sec_xmt[$2] += $8;
X sys_xf[$2] ++;
X}
X#
X# 4.2 BSD UUCP
X$5 == "sent" {
X sysname[$2] = $2;
X by_xmt[$2] += $7;
X sec_xmt[$2] += $9;
X sys_xf[$2] ++;
X}
X#
X# System V UUCP
X$6 == "->" {
X $1 = substr($1, 1, (index($1, "!") - 1));
X sysname[$1] = $1;
X by_xmt[$1] += $7;
X sec_xmt[$1] += $9;
X sys_xf[$1] ++;
X}
XEND {
X#
X# print a report header
X printf("System Xfers Bytes rec Bytes xmt Connect Avg Xf Avg rec Avg xmt\n")
X for(i in sysname) {
X#
X# sort report by most connect time (selection sort)
X first = 0;
X for(j in sysname) {
X if (sys_xf[j] > 0) {
X tmp1 = sec_xmt[j];
X tmp2 = sec_rec[j];
X# Stupid AWK bug - needs a simple expression
X time = (tmp1 + tmp2);
X if (time > first) {
X first = time;
X sys = sysname[j];
X }
X }
X }
X#
X# 4.2 BSD awk seems to have problems. This check should not be necessary.
X# Oddly enough, this problem also shows up in System V. WHY???
X if (sys_xf[sys] != 0) {
X#
X# time for some bean counting
X tmp1 = sec_xmt[sys];
X tmp2 = sec_rec[sys];
X# Stupid AWK bug - needs a simple expression
X time = (tmp1 + tmp2);
X hours = time / 3600;
X sec = time % 3600;
X min = sec / 60;
X sec %= 60;
X tot_xf += sys_xf[sys];
X tot_by_rec += by_rec[sys];
X tot_by_xmt += by_xmt[sys];
X tot_time += time;
X#
X# protect myself against mathematical crime (divide by zero)
X if (sec_rec[sys] == 0)
X sec_rec[sys] = 1;
X if (sec_xmt[sys] == 0)
X sec_xmt[sys] = 1;
X#
X# print a pretty system report (god what an awful printf format...)
X printf("%-8s%8d%11d%11d%4d:%.2d:%.2d%8d%9d%9d\n", \
Xsysname[sys], sys_xf[sys], by_rec[sys], by_xmt[sys], hours, min, sec, \
X((by_rec[sys] + by_xmt[sys]) / sys_xf[sys]), \
X(by_rec[sys] / sec_rec[sys]), \
X(by_xmt[sys] / sec_xmt[sys]));
X#
X# make certain we will not see this system again... (selection sort)
X sys_xf[sys] = 0;
X }
X }
X#
X# calculate time split for total time (and print totals [*shudder*])
X hours = tot_time / 3600;
X sec = tot_time % 3600;
X min = sec / 60;
X sec %= 60;
X printf("\n%-8s%8d%11d%11d%4d:%.2d:%.2d\n", \
X "TOTALS", tot_xf, tot_by_rec, tot_by_xmt, hours, min, sec);
X}
X
SHAR_EOF
if test 2728 -ne "`wc -c < 'syslog_awk'`"
then
echo shar: error transmitting "'syslog_awk'" '(should have been 2728 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'SYSLOG'" '(132 characters)'
if test -f 'SYSLOG'
then
echo shar: will not over-write existing file "'SYSLOG'"
else
sed 's/^ X//' << \SHAR_EOF > 'SYSLOG'
Xuucp phri (9/22-5:19) (590923190) received data 12434 bytes 60 secs
Xuucp phri (9/22-5:19) (590923193) received data 98 bytes 1 secs
SHAR_EOF
if test 132 -ne "`wc -c < 'SYSLOG'`"
then
echo shar: error transmitting "'SYSLOG'" '(should have been 132 characters)'
fi
fi # end of overwriting check
# End of shell archive
exit 0
--
Frank
"Computers are mistake amplifiers."
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads