Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Perl CGI

Posted on 2000-04-28
6
696 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

839 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