'getline < "-" in awk script does not work!

'getline < "-" in awk script does not work!

Post by Toronto Mailland chinese Centr » Tue, 20 Oct 1998 04:00:00

Does anybody can help me solve this problem or circumvent it while I want an
interactive response in awk script.
Thank whoever response in advance!

'getline < "-" in awk script does not work!

Post by Ronelle van Nieke » Wed, 21 Oct 1998 04:00:00

try this:
echo - > file
in awk script:
getline < file

that should work.


Ronelle van Niekerk

tel: 400-4668


1. "getline < file" in awk

Getline < file doesn't seem to work. Here is a transcript of what I
tried. Any help in how getline can be made to work with redirected
input will be greatly appreciated. Thanks.
5:32pm copper bin>
5:32pm copper bin> cat z

#! /bin/sh
ps -ux | awk '{getline < /dev/tty}'

5:33pm copper bin>
5:33pm copper bin> ./z

awk: syntax error near line 1
awk: illegal statement near line 1

5:33pm copper bin>
5:33pm copper bin> man awk

     The ``function'' getline sets $0 to the  next  input  record
     from  the  current  input file; getline <file sets $0 to the
     next record from file.  getline x sets variable  x  instead.
     Finally, cmd | getline pipes the output of cmd into getline;
     each call of getline returns the next line  of  output  from
     cmd.   In  all  cases,  getline  returns  1 for a successful
     input, 0 for end of file, and -1 for an error.
Vijay Baliga
Phone: (812) 323 1445

2. Need help with Creative Sound Blaster PCI64

3. ftp in script works until imbedded in loop then receive "`<<' unmatched"

4. 1024 cylinder limit

5. Why "$ read name < file_name" doesn't work in sh script ?

6. IDE disk contoller and segmentation faults

7. """"""""My SoundBlast 16 pnp isn't up yet""""""""""""

8. multia info

9. Why doesn't echo "text" 'command' "more text" work?

10. <Script Language="Javascript" SRC=...></Script> under Apache

11. Why doesn't echo "text" 'command' "more text" work?

12. while ((getline variable <"file") > 0)

13. Condition checking "<=" and ">=" in ksh script