Mar 28, 2007 #1 ovince Programmer Joined Feb 27, 2007 Messages 55 Location FR hi, could somebody tell what is wrong with this command awk 'BEGIN {"read c" | getline vc close("read c"); print vc}' the idea is to read in some variable from STDIN and to use it in awk commands thanks oliver
hi, could somebody tell what is wrong with this command awk 'BEGIN {"read c" | getline vc close("read c"); print vc}' the idea is to read in some variable from STDIN and to use it in awk commands thanks oliver
Mar 28, 2007 #2 feherke Programmer Joined Aug 5, 2002 Messages 9,541 Location RO Hi If the executed command does not have an output, the [tt]getline[/tt] has nothing to read. The [tt]read[/tt] shell function has no output. Code: awk 'BEGIN {"read c[red]; echo $c[/red]" | getline vc[red];[red] close("read c"); print vc}' Feherke. http://rootshell.be/~feherke/ Upvote 0 Downvote
Hi If the executed command does not have an output, the [tt]getline[/tt] has nothing to read. The [tt]read[/tt] shell function has no output. Code: awk 'BEGIN {"read c[red]; echo $c[/red]" | getline vc[red];[red] close("read c"); print vc}' Feherke. http://rootshell.be/~feherke/
Mar 28, 2007 #3 Annihilannic MIS Joined Jun 22, 2000 Messages 6,317 Location AU This is the technique I have used in the past to request user input in an awk script: [tt]awk -v TTY=`tty` 'BEGIN { getline < TTY ; print "you entered " $0 }'[/tt] Annihilannic. Upvote 0 Downvote
This is the technique I have used in the past to request user input in an awk script: [tt]awk -v TTY=`tty` 'BEGIN { getline < TTY ; print "you entered " $0 }'[/tt] Annihilannic.
Mar 28, 2007 1 #4 PHV MIS Joined Nov 8, 2002 Messages 53,708 Location FR With unix you may try this: awk ' BEGIN{t="/dev/tty";printf "Value of c ? ">t;getline<t;vc=$1;print vc} ' Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886 Upvote 0 Downvote
With unix you may try this: awk ' BEGIN{t="/dev/tty";printf "Value of c ? ">t;getline<t;vc=$1;print vc} ' Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
Mar 28, 2007 #5 Annihilannic MIS Joined Jun 22, 2000 Messages 6,317 Location AU Yeah, that's better PHV. Annihilannic. Upvote 0 Downvote