Solved

Perl CGI

Posted on 2000-04-28
6
693 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:hasnida
Comment Utility
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
Comment Utility
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
Comment Utility
Thanx a lot .
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

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

13 Experts available now in Live!

Get 1:1 Help Now