?
Solved

CGI••  Generating a Dynamic page; converting to HTML page (workable)

Posted on 2006-05-18
9
Medium Priority
?
219 Views
Last Modified: 2013-12-25
I need assistance trying to generate a CGI dynamic page. Here are the details.

Here's the code that runs for perl:
http://www.oreillynet.com/pub/h/2688#code

if I run straight from perl, like this (I get this):

ns1:~/Sites/cgi-bin paul$ perl goolucky.cgi
Content-Type: text/html; charset=ISO-8859-1

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"><head><title>I&#39;m Feeling VERY Lucky</title>
</head><body><h1>I'm Feeling VERY Lucky</h1><form method="post" action="/goolucky.cgi" enctype="application/x-www-form-urlencoded">
Query: <input type="text" name="query" value="&quot;Grace Hopper&quot;" /> &nbsp; Domain: <input type="text" name="domain"  /> &nbsp; <input type="submit" name="submit" value="Search" /><p />Results:<p><b /> <br /> <a href></a> <br /> <i /></p><div></div></form></body></html>-ns1:~/Sites/cgi-bin paul$


now what I can't figure out is how to make this HTML page. Sometimes the book mentions to run a command like this:

perl goocook.pl > foo.html

again, I seem to be missing the next logical set.

if you could kindly assist me, I would greatly appreciate it. Please "dumb down" your response ;)


--Paul
0
Comment
Question by:paulpp
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 8

Expert Comment

by:Perl_Diver
ID: 16715538
I am not clear what you are asking, but if you want to see the results displayed as an HTML document you usually would run them through a web browser such as Internet Explorer or Mozilla. The script is a CGI script so you should be running it from a browser. Upload the script to your webhost (or run it from a local server if you have one) and then type in the url of the script in your web browser.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 16724202
> The script is a CGI script so you should be running it from a browser.
such a script is never (usually) run "through" a browser, nor by a browser

paulpp, the script has to be run by a web server which needs to be configured for CGIs, then the browser uses an URL to that CGI and the web server returns what you see when you call it from command line.
Or you run the script and redirect it to a file (your second example). This file then can be seen in the browser either on the same host you run the script, or from any where serverd by your web server with an URL to that (static) file.
0
 
LVL 8

Expert Comment

by:Perl_Diver
ID: 16725563
Yes, running "it from a browser" is correct. That is what I meant with saying "from" and "through" but I can see where that might confuse a person not familiar with CGI.
0
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 

Expert Comment

by:NapAiM
ID: 16728099
>> perl goocook.pl > foo.html

Yes that should output it to a file called foo.html in the same directory as the script, then you can open it from there
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 16729790
> This file then can be seen in the browser
dooh, have to correct this:
  this file "can" be seen in the browser, but it will show the HTML text as is, not rendered as expected.
you have to remove the  "Content-Type: .." line so that the file will be rendered by the browser.
0
 
LVL 2

Author Comment

by:paulpp
ID: 16730392
Hello,

when i run the script, i get a 500 error message. my web log states "a premature end of script headers".


--Paul
0
 
LVL 2

Author Comment

by:paulpp
ID: 16731138
Well i hate to report this; I'm so embarrassed :(  my perl location was not specified correctly. I had #!/usr/bclocal/perl , when i should have really used #!/usr/bin/perl


--Paul
0
 

Accepted Solution

by:
GranMod earned 0 total points
ID: 16928925
PAQed with points refunded (475)

GranMod
Community Support Moderator
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
Measuring Server's processing rate with a simple powershell command. The differences in processing rate also was recorded in different use-cases, when a server in free and busy states.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Suggested Courses
Course of the Month14 days, 8 hours left to enroll

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