I want to open a Unix domain socket for both reading and writing from an AWK script. I'm using Gnu AWK.
Accoring to this guide, ordinary sockets could be opened as "/net-type/protocol/local-port/remote-host/remote-port", where "net-type" is inet4 or inet6. But could Unix domain sockets be opened this way? I found nothing in the manual.
Anyway, this is what I tried. I want to write "status 3" command in the Unix socket and read the output back.
serv = "/var/etc/openvpn/serv.sock";
printf("status 3\n") |& ("nc -U " serv)
printf("wrote status command into serv.sock\n");
getline ans < serv
printf("ans = %s\n", ans);
But it doesn't read the data back.
$ gawk -f bwlimit.awk db.txt
wrote status command into serv.sock
newdata =