On Sat, 16 Feb 2008 10:55:43 -0600, Ted Davis
<tdavis@[EMAIL PROTECTED]
> wrote:
>On Sat, 16 Feb 2008 05:30:24 -0800, happytoday wrote:
>> Here is the path of the GTK-server and the example in the site with
that
>> error :
>> H:\programs\sedawk\Gtk>gawk -f test.awk gawk: test.awk:13: fatal: `|&'
not
>> supported
><snip>
>>
>> Any advice !!! Thanks for help
>
>There are several features of gawk that work only under *ix because other
>operating systems don't support them. You found one.
>
>There are two things you can do:
> A) find another way to handle the task, perhaps using a transient file
> B) run the program on a real Unix/Linux machine (not Cygwin - it's still
>limited by the underlying OS.
Yes, it's hard to find a gawk with 2way pipes for
MSWindows, but there is a cygwin gawk version that does.
It is called gawki.exe :
$ gawki --version
GNU Awk 3.1.1
Copyright (C) 1989, 1991-2002 Free Software Foundation.
It also supports 2way pipes to TCP / UDP ports.
Just for fun, here is the core of an awk script for gawki
that implements a webserver ("Lakota"):
===
dtsvcstart = strftime("%Y-%m-%d %H:%M:%S")
LakotaVersion = "2.2"
RC["200"] = "Ok"
RC["203"] = "Not found"
Listen = 80
httpd = "/inet/tcp/" Listen "/0/0"
printf("%s Lakota started\n",dtsvcstart)
headers = \
"HTTP/1.1 %s %s" ORS \
"Server: Lakota/" LakotaVersion ORS \
"Connection: close" ORS \
"Cache-control: no-cache, no-store" ORS \
"MIME-version: 1.0" ORS \
"Content-type: text/html" ORS
KeepRunning = (1 == 1) # true
while (KeepRunning){
print strftime("%Y-%m-%d %H:%M:%S Listen ") Listen
while ((httpd |& getline) > 0){
request = $0
# strip all control chars (0x0D 0x0A leftovers etc.)
gsub(/[[:cntrl:]]+/,"",request)
# strip leading whitespace
gsub(/^[[:blank:]]+/,"",request)
# strip trailing whitespace
gsub(/[[:blank:]]+$/,"",request)
if (request ~ /^GET /){
datetime = strftime("%Y-%m-%d %H:%M:%S")
URL = \
substr(request,5,index(request," HTTP/") - 5)
# getpage() :
# - reads the page from disk
# - handles invalid URLs and similar errors
# - if needed, generates an errorpage
# - sets status to 200 or 203,
# - may also change KeepRunning
#
html = getpage(URL)
contlen = length(html)
} # GET, other request headers are ignored
# empty line is end of request,
# so it's time to respond
if ($0 ~ /^[[:cntrl:][:blank:]]*$/){
printf("%s %s URL:%s:",datetime,status,URL)
printf(headers,status,RC[status]) |& httpd
printf("Content-Length: %d%s%s",\
contlen,ORS,ORS) |& httpd
printf("%s",html) |& httpd
break
}
}
printf("\n")
fflush("") # flush ALL output buffers
close(httpd) # keep-alive not honored
} # while (KeepRunning)
===
I use it as an "emergency" webserver, when Apache is down
for maintenance.
--
( Kees
)
c[_] If cleanliness is next to godliness then your desk
must be an atheist. (Geek horoscopes) (#354)


|