Re: Euphoria CGI, SVGA, and Pixel perfect collision dectection

new topic     » goto parent     » topic index » view thread      » older message » newer message

At 10:46 PM 6/1/98 -0700, you wrote:

>Buddy Hyllberg writes:
>>        1. is there a way to redirect STDIN & STDOUT globally?
>
>I'm not sure what you mean by globally, but the files STDIN and STDOUT
>relate to the predefined Euphoria file numbers 0 and 1, respectively.
>Irv's cgi files use temporary input and output files declared by the HTTP
>program ( the filenames are passed via environment variables).  I've got
>some CGI programs around here somewhere... one took a euphoria program off
>my hard drive, applied syntax coloring in html and returned it to the
>browser.

You can copy any of my CGI test programs, and change the
puts(fn.... to puts(1.... which is STDOUT. See if it works.
Note: you cannot just puts(1,"HELLO WORLD") and expect the
server to return it to the browser. There absolutely MUST
be a proper content header on the file: either text or html.
Here's a test file that implements a counter:

-- Euphoria CGI Webcounter Program
include file.e
include get.e

object outfile, fn, ok, count

  count = 0   -- get and update visitor count
  fn = open("C:\\httpd\\cgi-dos\\WEBCOUNT.DAT","u")
   if fn > 0 then
      count = get(fn)
      count = count[2]
      ok = seek(fn,0)
      printf(fn,"%d",count+1) -- increment the count
      close(fn)
   end if

  outfile = getenv("OUTPUT_FILE") -- open file and write header
  fn = open(outfile,"w")      -- you could try changing
  if fn > 0 then              -- fn to 1 and see if it will work
    puts(1,"Writing to file:"&outfile&"\n") -- debug message
    puts(fn,"Content-type: text/html\n") -- these two lines are
    puts(fn,"\n")                        -- required!
    -- note: the content-type line must
    -- be there and have a blank line after
    -- or you'll get a server error.
  else puts(1,"Error opening "&outfile)
       abort(0)
  end if

-- create the html code:
puts(fn,"<HTML><HEAD><TITLE>")
puts(fn,"Euphoria Web Server")
puts(fn,"</TITLE></HEAD>\n")

-- create the body code:
puts(fn,"<BODY>")
puts(fn,"<H2>Euphoria HTML CGI Webcount</H2>")
puts(fn,"<hr>")
printf(fn,"You are visitor #%d",count)
puts(fn,"<hr>")
puts(fn,"<a href=mailto:irv at ellijay.com>irv at ellijay.com</a>")
close(fn)

Regards,

Irv

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu