Solved

Perl CGI

Posted on 2000-04-28
6
695 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

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.
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.
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 …

777 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