bfdi533 has asked for the wisdom of the Perl Monks concerning the following question:

I have a simple report form that I need to be able to distribute on floppy and run on any pc running windows. The output from this is a text file that can be submitted later.

I was thinking that since all windows system have an html browser that I could do this with an html form and then send the output to a perl script using CGI to process the output and dump it to a file for later processing. The problem that I am having is getting the process to actually run the script. What I get instead of the executed code is the contents of the perl script in the browser.

I ultimately plan to use perl2exe to distribute the perl script so that I can run this from a floppy disk without the need for perl to be installed.

Is this possible? If so, how can it be done? Is there a solution that will work with both windows and linux if it can be done?

Ed

Replies are listed 'Best First'.
Re: perl cgi without webserver?
by chromatic (Archbishop) on Jul 06, 2003 at 06:55 UTC

    It's not difficult to write a small webserver using HTTP::Daemon or the newerish Net::HTTP (I think that's the name). Jellybean already does something similar. It should work with perl2exe or PAR. Drop me a line if you're interested.

      I am definitely interested in this. A small webserver that only handles the web form submission and a call to a cgi to parse it would be great. Possibly I could event wrap this all up so it would fit into a floppy even.

      Ed

Re: perl cgi without webserver?
by cees (Curate) on Jul 06, 2003 at 14:16 UTC

    As has been said above, you will need a web server if you plan to use CGI. But instead of writing one yourself, have a look at microweb. It is meant for running web sites off CDROMs, and hence is very small (although probably not small enough to run on a floppy). It has perl and CGI support built in and so it should work for you out of the box.

    The only drawback is that it is shareware, but if you are writing this for a company, then software costs shouldn't be a big issue.

    - Cees

Re: perl cgi without webserver?
by yosefm (Friar) on Jul 06, 2003 at 09:12 UTC
    Just to make it clear: in order to run a CGI perl script you need a web server (which windows does not come with, although who knows what Bill would do to choke the internet a little more...)

    It apears by what you said that you tried to view a local copy of the script without running it through a server. Am I right?

      yosefm,
      "which windows does not come with"

      I wanted to point out that many versions of Windows does indeed ship with the IIS web server. This doesn't negate your point, it just shows that having a web server on a Windows machine "out of the box" is more common than you would expect.

      Cheers - L~R

        Yes, that is true but it needs to be able to run on Windows 95, 98, ME, NT, 2000, XP. This is not possible for the 9x flavors to run IIS and I do not want to have to install any software to make this report work. That is why I was thinking of using HTML as every Windows machine has a browser.

        At work we are constantly having to make sure that people do not install IIS as it is so easy to overlook on Server platform Windows versions. I am aware of how easy it is. But, like I said, 9x is also a target for this and no installation of further software. I am not going to be able to distribute IIS on floppy so this is not an option.

        I do thank you for the reply as it is a very good point that is normally overlooked.

        Ed

Re: perl cgi without webserver?
by chunlou (Curate) on Jul 06, 2003 at 21:02 UTC
    You could try HTA, which runs like a limited standlone CGI without webserver. But you're solution might not need to be a CGI one, I don't know.

    HTA example:
    <html> <head> <TITLE>my tiny weeny tady lil test...</TITLE> <HTA:APPLICATION ID="HTAEx" APPLICATIONNAME="HTAEx" ICON="e.ico" WINDOWSTATE="normal" > </head> <body> <pre> <SCRIPT language="PerlScript"> use Win32::Script qw/WScript/ ; $output = WScript('Shell')->Exec("ls")->StdOut->ReadAll ; $window->document->write("\nFiles:\n\n$output") ; </SCRIPT> </pre> </body> </html>
    It lists the files you have in your current directory, assuming you have ls.exe in your DOS PATH. "dir" won't work since it's a command within command.com or DOS shell, not a executable by itself.

    ______________________
    Update: The file name of the example above should have an hta extension, not html; something like foo.hta.
Re: perl cgi without webserver?
by tcf22 (Priest) on Jul 06, 2003 at 15:54 UTC
    To do what you are talking about, you do need a webserver. Depending on the version of windows, it may come with IIS(Win2K,XP Pro), which you can install in the Add/Remove Window components. If you are running home versions(95, 98, XP Home) of windows then you may need to install Microsoft Personal Web Server, but i would recommend IIS.
Re: perl cgi without webserver?
by JamesNC (Chaplain) on Jul 07, 2003 at 03:32 UTC
    Have you considered using Tk? Instead of the Web-server approach? I have built standalone apps with Tk front-ends that are under 1.2MB using ActiveState's PerlApp.exe. You could build the form in Tk and then build a simple client server to submit the form(s).