Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Perl CGI

Posted on 2000-04-28
6
Medium Priority
?
708 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 15 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

926 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