Solved

Perl/CGI

Posted on 1997-04-17
12
1,150 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
Comment Utility
Can you list your HTML and perl script, as this sounds quite remarkable if true!
0
 
LVL 2

Expert Comment

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

Expert Comment

by:Voodoo
Comment Utility
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
Comment Utility
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
Comment Utility
Edited text of question
0
 
LVL 2

Expert Comment

by:igroove
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 2

Expert Comment

by:igroove
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
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 fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

763 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

10 Experts available now in Live!

Get 1:1 Help Now