On Feb 16, 9:18=A0pm, Kees Nuyt <k.n...@[EMAIL PROTECTED]
> wrote:
> On Sat, 16 Feb 2008 10:55:43 -0600, Ted Davis
>
>
>
>
>
> <tda...@[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
tha=
t
> >> 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. =A0You 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"):
>
> =3D=3D=3D
> =A0 =A0 =A0 =A0 dtsvcstart =A0 =A0=3D strftime("%Y-%m-%d %H:%M:%S")
> =A0 =A0 =A0 =A0 LakotaVersion =3D "2.2"
>
> =A0 =A0 =A0 =A0 RC["200"] =3D "Ok"
> =A0 =A0 =A0 =A0 RC["203"] =3D "Not found"
> =A0 =A0 =A0 =A0 Listen =A0 =A0=3D 80
> =A0 =A0 =A0 =A0 httpd =A0 =A0 =3D "/inet/tcp/" Listen "/0/0"
> =A0 =A0 =A0 =A0 printf("%s Lakota started\n",dtsvcstart)
> =A0 =A0 =A0 =A0 headers =3D \
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "HTTP/1.1 %s %s" ORS \
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "Server: Lakota/" LakotaVersion ORS \
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "Connection: close" ORS \
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "Cache-control: no-cache, no-store" ORS
\
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "MIME-version: 1.0" ORS \
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "Content-type: text/html" ORS
>
> =A0 =A0 =A0 =A0 KeepRunning =3D (1 =3D=3D 1) # true
> =A0 =A0 =A0 =A0 while (KeepRunning){
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 print strftime("%Y-%m-%d %H:%M:%S Listen
"=
) Listen
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 while ((httpd |& getline) > 0){
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 request =3D $0
> # strip all control chars (0x0D 0x0A leftovers etc.)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
gsub(/[[:cntrl:]]+/,"",req=
uest) =A0 =A0 =A0
> # strip leading =A0whitespace
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
gsub(/^[[:blank:]]+/,"",re=
quest) =A0 =A0 =A0
> # strip trailing whitespace
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
gsub(/[[:blank:]]+$/,"",re=
quest)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (request ~ /^GET /){
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 datetime
=
=3D strftime("%Y-%m-%d %H:%M:%S")
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 URL =3D
\
> substr(request,5,index(request," HTTP/") - 5)
>
> # getpage() :
> # - =A0reads the page from disk
> # - =A0handles invalid URLs and similar errors
> # - =A0if needed, generates an errorpage
> # - =A0sets status to 200 or 203,
> # - =A0may also change KeepRunning
> #
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 html =3D
g=
etpage(URL)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 contlen
=
=3D length(html)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } # GET, other request
hea=
ders are ignored
>
> # empty line is end of request,
> # so it's time to respond
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ($0 ~
/^[[:cntrl:][:bla=
nk:]]*$/){
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
printf("%s=
%s URL:%s:",datetime,status,URL)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
printf(hea=
ders,status,RC[status]) =A0 |& httpd
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
printf("Co=
ntent-Length: %d%s%s",\
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
=
=A0 =A0 contlen,ORS,ORS) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 |& httpd
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
printf("%s=
",html) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 |& httpd
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 printf("\n")
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fflush("") =A0 =A0 =A0 =A0 =A0 =A0 =A0
=A0=
=A0 =A0# flush ALL output buffers
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 close(httpd) =A0 =A0 =A0 =A0 =A0 =A0#
keep=
-alive not honored
> =A0 =A0 =A0 =A0 } # while (KeepRunning)
> =3D=3D=3D
>
> I use it as an "emergency" webserver, when Apache is down
> for maintenance.
> --
> =A0( =A0Kees
> =A0 )
> c[_] If cleanliness is next to godliness then your desk
> =A0 =A0 =A0must be an atheist. (Geek horoscopes) =A0(#354)- Hide quoted
te=
xt -
>
> - Show quoted text -
If you run this script under windows . What are the step did you take
to run them under windows ?


|