Re: CGI in Euphoria

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

Buddy admits:
> Sorry, I was kinda vague :)
>
> Basically what I want to do is be able to use a language (such as Perl
> or Euphoria), and use it for CGI scripting *locally*. Like be looking at
> a local page, then filling out a form & running a script, and having the
> script return its results to the browser, not the console... just like
> what would happen if you were surfing online.
>
> Can it be done?

Sure.  Here's how I do it:

1. install some web server software (Irv uses HTTPD for win3.1, I've tried
Website Pro and Xitami web servers, both for win95)

2. create the Euphoria "script".  Here's a sample script that I've used to
print out some basic information:

-- code begins:  c:\euphoria\eusample.ex --
puts(1, "Content-type: text/plain\n\n")
puts(1, "Sample Euphoria & Standard CGI program:\n\n")

constant cm = command_line()
puts(1, "cm = command_line()\n")
printf(1, "length(cm) = %d\n", {length(cm)})
for i = 1 to length(cm) do
    printf(1, "cm[%d] = \"%s\"\n", {i, cm[i]})
end for

constant cp1 = getenv("PATH_INFO")
constant cp2 = getenv("PATH_TRANSLATED")

puts(1, "\nPATH_INFO = \"")
if sequence(cp1) then puts(1, cp1) end if
puts(1, "\"\nPATH_TRANSLATED = \"")
if sequence(cp2) then puts(1, cp2) end if
puts(1, "\"\n")
-- code ends --

3. Now find your web server software's cgi-bin directory.

4. now you have two choices:
  a. bind your program into an exe file and place the .exe in the cgi-bin
directory.
  b. create a batch file that executes your .ex file and place the .bat
file in the cgi-bin directory.  Here is an example batch file for eusample.ex:
 @c:\euphoria\bin\ex.exe c:\euphoria\eusample.ex %1 %2 %3 %4 %5 %6 %7 %8 %9
Note: if your program doesn't use command line parameters, you can omit
the %-stuff.  If your program does use them, you can obviously only have 9
parameters.  You may not have the parameter limit when binding to an exe.

5. To execute the script from a browser, just surf to
"http://your.server.com/cgi-bin/eusample.bat" or
"http://your.server.com/cgi-bin/eusample.exe".  The server should
recognize exe and bat files and executables.  The server software should
also handle sending form input, and capturing output and returning it to
the browser.  "your.server.com" is your ip address - your server software
will explain more about that.

Still, I'm not sure if you can do this locally... check your web server
software to see if it supports that.

Hope this helps,
 _______  ______  _______  ______
[    _  \[    _ ][ _   _ ][    _ ]
[/| [_] |[/| [_\][/ | | \][/| [_\]
  |  ___/  |  _]    | |     |  _]
[\| [/]  [\| [_/] [\| |/] [\| [_/]
[_____]  [______] [_____] [______]
       xseal at harborside.com
http://www.harborside.com/home/x/xseal/euphoria/
ICQ: 13466657

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

Search



Quick Links

User menu

Not signed in.

Misc Menu