Solved

Perl CGI

Posted on 2000-04-28
6
694 Views
Last Modified: 2013-11-18
Hi,

I'm new in Perl/CGI world. I have a html page that contains a call to .cgi file. However, seems like it doesn't work. I did install a Sambar Web Server in my pc & load the cgi-lib.pl in my /cgi-bin directory.

I have no ideas in solving this probs.

test.html--->put it inside /docs directory.

<html><head>
<title>Testing</title></head>
<body>

<form method=post action="test.cgi">
<br>Name : <input name="name"><br><p>
Age : <input name="age"><p>

<input type="submit" value="submit">
</form>

</body>
</html>

test.cgi---> put it inside /cgi-bin directory.

#!/usr/local/bin/perl

require "cgi-lib.pl";

MAIN:
{

&ReadParse(*input);

print &PrintHeader;
print &HtmlTop ("cgi-lib.pl demo");

($text=$input{'text'}) =~s/\n/\n<br>/g;

print <<ENDOFTEXT;

hai $input('name')

ENDOFTEXT

print &HtmlBot;

}


one more q, i've read about cgi.pm. What is this for actually?

Thanx in advance. :)
0
Comment
Question by:hasnida
6 Comments
 
LVL 6

Expert Comment

by:christopher sagayam
ID: 2759880
have you tried

#! c:\perl\bin\perl.exe instead of

#! usr/local/bin/perl  ?

 
what are the errors you get ?

have you installed activeperl from activestate.com ?



0
 
LVL 1

Expert Comment

by:lambda
ID: 2760423
Instead of
<form method=post action="test.cgi">

U may have to use,

<form method=post action="/cgi-bin/test.cgi">

0
 
LVL 1

Expert Comment

by:lambda
ID: 2760546
For info on cgi.pm, go to
http://www.irt.org/articles/js171/

U can also go to www.irt.org & do a search for CGI.pm.


£.
0
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.

 

Author Comment

by:hasnida
ID: 2761285
Thanx 4 the comments...

I've already tried the solution that both of you suggested but the result was that after clicking the submit button the application did not process the form, instead it shows the content of the .cgi file.

fyi, i have installed activeperl in my desktop.

what is going on here? do i have to load any files or modules? btw, i run it at dos prompt & it works !!! at least, huh :)

Tq again guyz.
0
 
LVL 2

Accepted Solution

by:
bertvermeerbergen earned 5 total points
ID: 2762644
cgi.pm:
I don't know cgi-lib.pl, but in the documentation for cgi.pm there is a paragraph on converting from it.  Looking at this doc, I suppose cgi.pm is a newer (better ?) object oriented implementation that does the same thing as cgi-lib.pl and then some.

Your problem:
The '#!' (she-bang) line is not taking into account to run a script on a PC (although the specified flags are, if I recall correctly).
Normally, the file extension is used to know what program to run for a given script (like .pl to invoke the perl executable).
With PWS (from microsoft), you need to add a line in the registry for every file extension you want to be recognized as a script to run and specify the program to run.  The 'normal' file extension <-> program relation already defined for an interactive session (like a command prompt or from explorer) do not apply here.
Since your script is displayed on the browser screen, this could indicate that such a relation is missing (for the file extension .cgi you use) in your Web server setup.  The default action would then be to show the contents of the file instead of run it as a script.
The documentation for your web server should tell you how to configure this.
0
 

Author Comment

by:hasnida
ID: 2767826
Thanx a lot .
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

Suggested Solutions

Title # Comments Views Activity
how to extract window origin in spring 2 63
I starting with php 12 112
Lines Not Lining Up 2 62
Windows and other UI names - The Proper names for the Various elements! 1 55
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

943 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

15 Experts available now in Live!

Get 1:1 Help Now