Solved

Perl/CGI

Posted on 1997-04-17
12
1,167 Views
Last Modified: 2013-12-25
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>














































0
Comment
Question by:topcat1
  • 6
  • 4
  • 2
12 Comments
 
LVL 2

Expert Comment

by:Voodoo
ID: 1827916
Can you list your HTML and perl script, as this sounds quite remarkable if true!
0
 
LVL 2

Expert Comment

by:Voodoo
ID: 1827917
Can you list your HTML and perl script, as this sounds quite remarkable if true!
0
 
LVL 2

Expert Comment

by:Voodoo
ID: 1827918
Can you list your HTML and perl script, as this sounds quite remarkable if true!
0
 
LVL 2

Accepted Solution

by:
igroove earned 100 total points
ID: 1827919
Two things could be happening:

FIrst, on your machine:
What's happening is your browser is prolly thinking that the perl script mime type is text/plain or associates files of the type .cgi or .pl as text files, and therefore decides to "download" and "view" them rather than execute them.

You should look (in the registry) under .pl or .cgi in HKEY_CLASSES_ROOT,  and see the "long name" of a perl file. It's probably perlfile or plfile or cgifile.  Check under that key if there's a shell subbkey, and an open key, and a command key under that, ie:

HKEY_CLASSES_ROOT/plfile/shell/open/command/

It may reference wordpad.exe in it.  If so, remove it.
You may also have to look under your mime types for cgi/pl and remove it being text/plain or text/html.

If you're running a web server, you have to get it to recognize .cgi or .pl as scripts.  I run NT4 Server and Internet Information Server, so I had to go under it's registry and tell it .cgi meant go do perl.

Basically, that's what's happening on your local system.

Second, on your 'net providor's machine:

At your web hosting (ISP) it may be that you cannot run a script anywhere but their cgibin.  You may have to ask them about that.
If you can run one in your web home, then make sure that the file is EXECUTABLE.  What could be happening is that the server doesn't see that your CGI is an executable script.  You should set the mode of the CGI file to 755. (permissions), if your host is UNIX.  That means the file is READABLE and WRITEABLE and EXECUTABLE by you, the owner of the file, and only READABLE and EXECUTABLE by others. (rwxr-xr-x).  If this is confusing, you need to brush up on a little unix file permissions.

Basically, you gotta let the web server know your file is an executable script.  As i said b4, ask your providor. or consult your web server doc (if that's the case)

You didn't provide a lot of intel in your question, so I hope I've explained it :)
0
 

Author Comment

by:topcat1
ID: 1827920
Edited text of question
0
 
LVL 2

Expert Comment

by:igroove
ID: 1827921
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
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 2

Expert Comment

by:igroove
ID: 1827922
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"

0
 
LVL 2

Expert Comment

by:igroove
ID: 1827923
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... :)

0
 
LVL 2

Expert Comment

by:igroove
ID: 1827924
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.

0
 
LVL 2

Expert Comment

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

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

0
 

Author Comment

by:topcat1
ID: 1827926
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
0
 
LVL 2

Expert Comment

by:igroove
ID: 1827927
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now