Add Your Resource Instantly
Member Registration
Vendor Registration

Vendor Login
Perl Tutorials & Support
Search The Perlmasters Index
Contact The Webmaster
Custom CGI Programming
Advertising Opportunities
Website Monitoring Tools

cgi scripts in perl

 New (updated hourly):
Top Technology News

Can't find what you need?
Click here to request a custom quote



Keyword(s) Category

I'm not guaranteeing anything, but it works for me!

  • First - you must be running WindowsNT (I'm running 3.51 Workstation)
  • Obtain a copy of Perl for Win32 via ftp or WWW.

      110-i86.zip is the file for Intel processors as at this date.

  • Obtain a copy of EMWAC HTTP server (version 0.99 at least) via ftp or WWW

    note: I am assuming you can unzip it when you get it.

I suggest unzipping the http server software under your Internet directory, and your perl software either under a Perl directory or a programming directory - for security reasons don't put it under your Web data directory.

  • Follow the directions for installing both sets of software.

    Read Install.txt for information on installing Perl. Don't move these files once you have installed Perl as it sets up Registry entries - and it adds the Perl\bin directory to the path (under ControlPanel\System).

  • create a directory that will be the top of your data directory for your .html files - like \pub or \public.

    You should have an HTTPS applet under Control Panel. Click on this and set your \pub (or whatever you called it) directory for the start of the Data Directory.

  • Under Services - start the EMWAC https service (you may wish to change the Startup parameters to make it automatic)

------ that was the easy part -------

I am assuming that you can create HTML forms, or at least edit them. If not - may I suggest a very good tutorial.

Most info on Perl scripts and cgi-enabling is for Unix boxes - so here is the elusive info you will need.

the #!/usr/local/bin/perl line at the top of the script is what tells the Unix command shell where to find the Perl.exe file.
This doesn't work under NT! Instead - do the following:

  • You must FileAssociate .pl files to perl.exe under your Perl\bin directory. (note that you might have other perl.exe files scattered around - if unsure look in the System applet under Control Panel and look at the Path under System variables)
  • make sure that the line containing push(@INC,"/pub/cgi-bin/"); is correct -ie. full path name.
    (/pub/cgi-bin/ is the directory under your DataDirectory where you want to store your cgi-scripts). you may need to push(@INC,"/other/directories/"); if you "require" scripts stored elsewhere (I haven't tested this yet).
    Note that you don't need to have anything except your cgi-scripts here. The other .pl files can happily sit in perl\5.001\lib or whereever.
  • I would suggest grabbing a copy of cgi-lib.pl and sticking it in your cgi-bin directory (as noted in the above tutorial on HTML forms)
  • in your HTML form - call the script as follows:
    <form method="POST" action="http://www.your.server.name/cgi-bin/your_script.pl">            

      I suggest using the POST method - it's more secure and handles more information than GET.

      www.your.server.name = the machine you are putting this on.

      /cgi-bin/ = the directory path to where your cgi-scripts are located (not including the Data Directory root directory). (ie. mine is \pub\cgi-bin but as \pub is the Data Directory (as specified in the https applet under Control Panel) I only need \cgi-bin.

      your_script.pl = whatever you have called your script.

      Never use <action="http://www.your.server.name/perl.exe /cgi-bin/your_script.pl">

      a hacker could reformat your harddrive - or worse!!

    The dreaded "Document contains no data" message? :-(
    This could be for a number of reasons, like

    • you haven't installed Perl properly
    • you haven't left a blank line in your script's return message

        should have print "Content-type: text/html\n\n"; instead of
        print "Content-type: text/html\n"; (note the extra newline)

      please let me know of any more if you find any

    It's in the docs, but I'll mention it here again:
    Make sure that the System has at least read and execute access to your scripts.
    It'll need write as well if you are making changes to files etc.
    It's probably just as easy to give the system full access to the data directory tree (including scripts directory) as default, and if you really want to tighten security, tighten access in the places where you want it tightened. (Note the system will also have to be able to execute perl.exe [which won't be under the data directory tree]).

    I think that most other things can be nutted out from reading the docs but if you run into any walls - or you think I need to add or change something here - let me know.


 

1999-2000 DRS Services