randy@amsaa-cleo.brl.mil (Randy Sebra <randy>) (11/26/90)
Hello, I have tried unsuccessfully to use the 'system' and 'close' functions in an AWK script. I have tried this on a Gould 9080, Pyramid MIS-4, and an Alliant FX/8 on their ports of UNIX. None seems to give the results I would expect from reading the book "The AWK Programming Language" by A,W,and K. The following examples : awk '{ system("ls -lg /etc") }' /dev/null awk '{ system("ls -lg /etc > /tmp/list") }' /dev/null are simple one-liners which produce no output/results, and the function does not work any better in a more complicated script. Also surprising is that even though nothing is accomplished in either, I do not get an error message which would indicate that at least the syntax is correct. Similarily, the close() function does not(apparently) do anything as per this example : print $0 > "foofile" ... close("foofile") which was used in order to keep under the limit of 10 open files, but the program still bombs with the message : awk: too many output files 10 record number 11 I am I missing something really elemental here?? Randy Sebra Army Materiel Systems Analysis Activity Attn: AMXSY-DA Aberdeen Proving Ground, Maryland 21005-5071 Phone: (301) 278-6679 (AV) 298-6679
fuchs@it.uka.de (Harald Fuchs) (11/28/90)
randy@amsaa-cleo.brl.mil (Randy Sebra <randy>) writes: > I have tried unsuccessfully to use the 'system' and 'close' >functions in an AWK script. >awk '{ system("ls -lg /etc") }' /dev/null >awk '{ system("ls -lg /etc > /tmp/list") }' /dev/null Anything between { and } is executed for each input line (unless a pattern is specified). Since there are no input lines, nothing is executed. Besides that, your script is syntactically OK. -- Harald Fuchs <fuchs@it.uka.de> <fuchs%it.uka.de@relay.cs.net> ... <fuchs@telematik.informatik.uni-karlsruhe.dbp.de> *gulp*