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

Is there a way to load a Perl script from within a web page without requiring any user intervention?

Thanks

Eoin

Replies are listed 'Best First'.
Re: Executing Perl Script from a Web Page
by fuzzyping (Chaplain) on Feb 11, 2003 at 12:48 UTC
    Of course. A simple way is to source it inside a frame.
    <html> <head> <title></title> </head> <frameset> <frame src="/cgi-bin/test.cgi"> </frame> </frameset> </html>
    -fp

    Update: Obviously, another way would be to do a redirect with a meta refresh.
Re: (nrd) Executing Perl Script from a Web Page
by newrisedesigns (Curate) on Feb 11, 2003 at 13:03 UTC

    If it's an option, Apache's SSI would work.

    Why do you need it to run without intervention? What are you trying to do?

    John J Reiser
    newrisedesigns.com

      Thanks John

      I'm in a Win32 environment with IIS.

      Here's what I'm trying to do:

      1. I'm uploading a large file and I need a way of letting the user know that something is happening.

      2. I'm using the javascript onSubmit event handler within the form to launch a web-page in another window. I don't think you can call a Perl script with this javascript event handler.

      3. I want the web-page opened in the second window to run a Perl script which will try and find out the progress of the file upload and let the user know.

      4. The above, of course, doesn't solve the problem of IIS timing out during a long file upload but that's another days work.

      Merlyn has written a example script that uses fork to deal with the problem of monitoring long running processes but it is a Unix based script and I couldn't get it to run in a Win32 environment and I'm not even sure if it can be adapted for Win32.

      Thanks

      Eoin

        2. I'm using the javascript onSubmit event handler within the form to launch a web-page in another window. I don't think you can call a Perl script with this javascript event handler.

        Not that I like js solutions but you can open anyfile in a new window using any handlers, just do:

        <form method="post" action="youscript.cgi" onSubmit="open('your_check_ +script.cgi')">

        You can pass some extra parameters to the open function to define how you want it to appear (size scrollbars etc.)

        Hope that helps.
        Chris

        Lobster Aliens Are attacking the world!

        Correction to my previous post to John

        You can launch a Perl script from javascript

        example:

        <SCRIPT LANGUAGE="JavaScript"> function showProgress() { var newWindow = open("http://localhost/cgi-bin/test.pl", "secondWindow +", "scrollbars,resizable,width=250,height=150,left=720"); } </script>

        The form element would contain the following javascript event handler:

        onSubmit="showProgress()

        Eoin

        This depends on a few things... but, you could have a Perl script that watches the file upload by how much of the file is uploaded so far. You can steal the size of the file from the Content-size: header, pass it to the second script as a query string, and have the script return a page with a meta refresh tag so the page will reload every second or so.

        That's putting more strain on the server; how important is it to have a window display the current upload?

        John J Reiser
        newrisedesigns.com