Link to home
Start Free TrialLog in
Avatar of topcat1
topcat1

asked on

Perl/CGI

I am trying very hard to get my HTML script to call a simple Perl script.  What is happening is that when the HTML calls the Perl script, the Perl script is brought up in WordPad.  What is going on please ?

I am under the impression that as long as I have Perl on my system, I have no need to call out to my ISP's cgibin directory.

thanks,

topcat1

To follow up to your answers:

Thanks for your answers.  I have enclosed the scripts as you asked.  I altered the H_KEY_CLASSES_ROOT as suggested; sure enough WordPad.exe was in there, so I took it out.

Now when I run the guest.htm and press submit to call the Perl script, it tells me that :  "This file does not have a program associated with it for performing this action.  Create an association in My Computer by clicking View and then clicking options."  So I went there, and under .PL files, it just says that the action is open.  I also checked out my MIME setup in the Registry and there was nothing referring to .pl files, just an entry for html/text, which had a few fields in it that obviously meant something, but not to me.

Regarding the question about my ISP's cgibin directory, what I meant was, I should be able to get this all to run on my PC, as long as I have all the necessary bits and pieces, correct?  Do I need to specify the location of perl.exe and perl100.dll in my Registry?

Any further help is much appreciated !  Sorry about lack of points for the answer, I seem to be running a little short.

TC1


Here is my Perl script :

#! perl
print("My name is Yon Yonson,\n");
print("I live in Wisconsin,\n", "I work in a lumbermill there.\n");

Here is the HTML that calls it (First.pl)

<html>
<head>
<title> MOUSEPADKING Guestbook</title>
</head>
<body background="whamback.gif" vlink="#FF00FF">

<center><h2>Add to our Guestbook</h2></center>

Give us some feedback; what would you like on your mousepad ?

  Is there a favorite picture that you would like us to put on your pad for you?    

<b>Put some picture in your life !!!!</b>
<br>

<a href="list.htm"><font size=+1 color="#000000" face="Times New Roman"><b>BACK</b></font></a>

<FORM METHOD="POST" ACTION="D:\PERL\First.pl">
<table border=0 cellpadding=10>
<tr>
<td>Your Name:</td>
<td><input type=text name=name size=30></td>
</tr>
<tr>
<td>Email:</td>
<td><input type=text name=email size=40></td>
</tr>
<tr>
<td valign=top>Comments:</td>
<td><textarea name=comments cols=60 rows=4></textarea></td>
</tr>
</table>
<input type=submit value="Add Entry"><input type=reset>
</form>




</body>
</html>














































Avatar of Voodoo
Voodoo

Can you list your HTML and perl script, as this sounds quite remarkable if true!
Can you list your HTML and perl script, as this sounds quite remarkable if true!
Can you list your HTML and perl script, as this sounds quite remarkable if true!
ASKER CERTIFIED SOLUTION
Avatar of igroove
igroove

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of topcat1

ASKER

Edited text of question
Ok, yes, you should be able to run it locally if you wish.  Here's some things you should do:

1)  Your first line of your script should read:
#!/usr/bin/perl

This is so that when you upload it to a server, the server will know where Perl is and stuff.

2)  If you're running Microsoft's Internet Information Service, you drill through the registry to get to:
HKEY_LOCAL_MACHINE/System/CurrentControlSet/Services/W3SVC/Parameters/Script Map/

Add a REG_SZ key ".cgi" with a REG_SZ value of "c:\Perl\Bin\Perl.exe %s %s" or your path to Perl.

This will tell IIS to run .cgi files w/Perl.

You should, even if you aren't running IIS, change .pl files for CGI to .cgi.

3) If you're not running IIS, check your server documentation for nessicary setup file/registry/.ini settings to get the server to run .cgi files w/perl.

4)Drill in your registry to:
HKEY_CLASSES_ROOT/.pl/ and see what the long name of file is (as before when you had to find it to remove wordpad).  Go to the HKEY_CLASSES_ROOT/plfile or whatever it specifies.

For HKEY_CLASSES_ROOT/perl(or whatever)/shell/open/command/ make sure the value is "perl.exe %1 %*" so that it will run .pl files with Perl in the shell.

Then add HKEY_CLASSES_ROOT/.cgi/ with the same value that HKEY_CLASSES_ROOT/.pl/ has.

You should, theoretically, now be able to do as you wish.

BTW, what Perl for win are you using PerlWin32?  To me, it's the best Perl port yet. :)

Happy scriptiing!
Igroove
Ok, to summarize the registry:

Assuming you have HKEY_CLASSES_ROOT/.pl/ pointing to "perl", and Perl.exe is in c:\Perl\Bin:

The registry values would be:
HKEY_CLASSES_ROOT/.pl/ = "perl"
HKEY_CLASSES_ROOT/.cgi/ = "perl"
HKEY_CLASSES_ROOT/perl/shell/open/command = "perl.exe %1 %*"

And if you're running IIS on NT4.+:
HKEY_LOCAL_MACHINE/System/CurrentControlSet/Services/W3SVC/Parameters/Script Map/ -- add a value named ".cgi" equal to "c:\Perl\bin\Perl.exe %s %s"

Of course, c:\Perl\bin must be in your path...or wherever your perl binaries are.  Check your perl install docs to get it right.

That's all... :)

Also, your perl script won't actually run from an HTML unless it's called VIA a server...but it'll run just fine standalone (ie, you type some_file_name.pl on the command line).  That may be the biggest problem you're having.  A browser itself cannot run a cgi script.  That's a server-side thing.

Hope this all clears it up for you.  If you need a server, try http://www.w3c.org/ and pick up their FREE httpd.  THey've got one that runs under Win32, and does a good job.

Another web server you may want to try is Omni HTTPd. You can find it at:

http://www.fas.harvard.edu/~glau/httpd/

Avatar of topcat1

ASKER

I think that my problem is that I am trying to run it all on my machine.  I did not realize that a browser could not invike a Perl program; but then how was I supposed to know; I'm just a dumb Paddy.  Voodoo, just for you, I was a Fortran77 programmer in London for 3 years, back in the early 80s,  but California had my name on it, so now I experience the savours of American life! You both recommend servers for me to use, what is the difference between them and my ISP, Primenet ?

bye for now, topcat
Fortran!  Hehe.  Reminds me of ......cp/m....forth....et al.

HTTP servers are basically the same, save for different ways they handle server side includes and stuff.

JavaSoft has a really cool one called Jeeves that will run Java "servlets" - Java applets that run server side instead of on a client!  Pretty phat if you ask me.

And ColdFusion is a good server too.  I use Microsoft's IIS locally, but my pages are hosted on a Linux box running a stock httpd, so really cool server side scripting is basically nil.