ericw@janis.UUCP (Eric Wedaa) (04/27/91)
I've been having some troubles with awk under Ultrix 3.0 and 3.1. I am attempting to get a system call to function, but it just plain refuses to work. For example: awk '{system("date")}' test.file produces NO output. I've tried several flavors of calling it, and it still fails. It also always returns a succeed result to an "if " statement. Any ideas? >>>Eric -- ===================================================================== | These views are mine, and not those of my company or co-workers. | =====================================================================
jiml@uwslh.slh.wisc.edu (James E. Leinweber) (05/02/91)
ericw@janis.UUCP (Eric Wedaa) writes: >I've been having some troubles with awk under Ultrix 3.0 and 3.1. ... > awk '{system("date")}' test.file ... produces NO output. Under Ultrix 4.1 on a Vaxstation 3100 and 4.3BSD Unix on an 11/750, I get: (/usr/1/wbacti) sente$ awk 'END{print system("date")}' < /dev/null date (/usr/1/wbacti) sente$ nawk 'END{print system("date")}' < /dev/null Thu May 2 11:15:14 CDT 1991 0 Consulting the documentation we have on the old and new awks, it appears that the system() function was one of the 1985 additions. Old awk evaluates system("date") as a concatenation of an uninitialized variable named "system" with a string "date". Since concatenation is implicit and so is variable initialization, this surprising behavior is required by the language definition. The solution is to get a recent version of awk. Upgrading to Ultrix 4.1 is one way; failing that I'd suggest getting the GNU awk clone "gawk" from your nearest comp.sources archive or the FSF. -- Jim Leinweber (608)262-0736 State Lab. of Hygiene/U. of Wisconsin - Madison jiml@sente.slh.wisc.edu uunet!uwvax!uwslh!jiml fax:(608)262-3257