views:

207

answers:

3

"awk: Function systime is not defined."

but systime is a built in command

+2  A: 

Seems to be a matter of awk "flavor".

GAWK (gnu awk) includes systime(), but maybe the version you are using does not...

Unless systime calls are meant to keep track of time differences within the awk script itself, a trick to circumvent the lack of awk systime() function would be to pass the value of this system variable as a variable on the awk command line.

mjv
+1  A: 

As an example, on my system both gawk and mawk are installed.

echo |mawk '{print systime()}'

produces:

mawk: line 2: function systime never defined

while

echo |gawk '{print systime()}'

produces:

1252953754
Dennis Williamson
+3  A: 

On Solaris, /usr/bin/awk is by default a link to /usr/bin/oawk, which does not recognize systime as a built in (or a lot of other extensions over the 7th Edition AWK). Either relink /usr/bin/awk to /usr/bin/nawk or use nawk directly, or get GNU Awk (gawk) installed and use that.

Other Unix systems like HP-UX, AIX may have similar issues. MacOS X (and, by inference, BSD) install a non-GNU, non-extended version of awk (thanks for the correction, DMcKee). Linux does not; it uses GNU Awk as the main/only awk. Of course, GNU Awk can easily be installed on any of these systems.

Jonathan Leffler
Correction: at least for 10.4 and 10.5 Mac OS does *not* use gawk by default. It is easily installed using fink (or presumably macports).
dmckee