[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: exit
From: |
Aharon Robbins |
Subject: |
Re: exit |
Date: |
Wed, 4 Feb 2004 15:22:27 +0200 |
Greetings. Re this:
> Date: Wed, 4 Feb 2004 13:33:45 +0100
> From: address@hidden
> To: Aharon Robbins <address@hidden>
> Cc: address@hidden
> Subject: Re: exit
>
> Look at this:
>
> address@hidden:~$ awk 'BEGIN { "date" | getline date; print date;
> system("sleep 2"); "date" | getline date; print date }'
> Wed Feb 4 13:27:36 CET 2004
> Wed Feb 4 13:27:36 CET 2004
> address@hidden:~$ awk 'BEGIN { "date" | getline date; print date;
> system("sleep 2"); "date -u" | getline date; print date }'
> Wed Feb 4 13:27:48 CET 2004
> Wed Feb 4 12:27:50 UTC 2004
>
> This is probaby the same problem with descriptors. If i use two times the
> same command through pipe i receive the same result. :(
>
> Jozef
>
> PS: i'm GMT+1
This is not a bug. It's documented behavior. The pipe stays open until
closed with close(). In this case, since the "date" command only produces
one line of output, the second getline does not change the `date' variable.
Since "date -u" is a different command, you do get different results:
$ cat > dateme.awk
BEGIN {
"date" | getline date
print date
close("date")
system("sleep 2")
"date" | getline date
print date
close("date")
}
$ awk -f dateme.awk
Wed Feb 4 15:20:59 IST 2004
Wed Feb 4 15:21:01 IST 2004
See the gawk manual.
Arnold
- exit, jozef . kutej, 2004/02/03
- Re: exit, jozef . kutej, 2004/02/04
- Re: exit,
Aharon Robbins <=
- Re: exit, Aharon Robbins, 2004/02/05