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

I need assistance trying to generate a CGI dynamic page. Here are the details.

Here's the code that runs for perl:

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"
<html xmlns="" 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 > 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 ;)

Who is Participating?
GranModConnect With a Mentor Commented:
PAQed with points refunded (475)

Community Support Moderator
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.
> 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.
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

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.
>> perl > 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
> 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.
paulppAuthor Commented:

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

paulppAuthor Commented:
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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.