For Programmers: Free Programming Magazines  


Home > Archive > AWK > February 2005 > Semantics of implicit "open" in gawk









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Semantics of implicit "open" in gawk
Stephan Titard

2005-02-08, 8:55 am

Hi, I seem to get recurrently bitten by this...
[color=darkred]
10:28:34:
$ gawk --source='BEGIN { print "ok" > "/hi1"; print "nope" }'
gawk: fatal: can't redirect to `/hi1' (Permission denied)

any way to catch this in pure gawk


could we have print return something useful (C-like or not) and catch it
(would be on par with getline no?)

thanks
steph
Kenny McCormack

2005-02-08, 3:55 pm

In article <42088912.5070607@rest.is.fake>,
Stephan Titard <sgt19_at_tid_dot_es@rest.is.fake> wrote:
>Hi, I seem to get recurrently bitten by this...
>
>10:28:34:
>$ gawk --source='BEGIN { print "ok" > "/hi1"; print "nope" }'
>gawk: fatal: can't redirect to `/hi1' (Permission denied)
>
>any way to catch this in pure gawk


Not without either:
1) Modifying the source code and recompiling. I did this once upon
a time, because I, like you, don't think these things should be fatal.
Actually, I did it in the context of the networking extensions, but, IIRC,
I also did it for the non-network branches.
2) Using something like: system("access ...") to test ahead of time.
Purists will point out that using any form of the access(2) system call
introduces a race condition.

>could we have print return something useful (C-like or not) and catch it
>(would be on par with getline no?)


See above.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com