Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CGI does not work properly

Posted on 1997-08-19
4
Medium Priority
?
173 Views
Last Modified: 2013-12-25
Hi, I am very new to Perl and HTML. I am currently creating a guestbook using html. If the user clicked on the submit button, I will called my perl file to check whether they have entered all the necessary fields.

If the form is not complete, I will then display another redopage html informing them.

But my redopage html does not get shown up. Is it possible for the perl to open up another html???

Below is my perl file which only consists of the calling part, but still the html does not get showed up. Did I miss out any library??? I am actually running it in Windows NT.

/*** my *.pl file ***/

use CGI;

$redopage="/olticket/jonr&d/redopage.html";
$redo;

sub redo
{
      print (REDOPAGE $redopage);
      while (<REDOPAGE>)
      {
           print $_;
      }
      Close(REDOPAGE);
      exit;
}
Could anyone please help.

Thank you.

Regards
Yann Ming
0
Comment
Question by:ymlew
[X]
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
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
icd earned 300 total points
ID: 1829729
The problem is that you are not opening the file. Try:-

sub redo
{
open (REDOPAGE $redopage);
while (<REDOPAGE>)
   {
   print $_;
   }
close(REDOPAGE);
}

Note that I changes 'print' to 'open'. I removed the 'exit' from the procedure. I changed 'Close' to 'close' (perl is case sensitive).

I think I found all the errors... but if it still does not work get back to me before grading the answer.

0
 

Author Comment

by:ymlew
ID: 1829730
I have tried it but it still does not work. I actually put a print statement after calling the redo sub-routine. My message got printed out, but the html just does not got showed up.

Did I miss out some library which I should have included???

Regards
Yann Ming
0
 
LVL 7

Expert Comment

by:faster
ID: 1829731
Before you print out the contents of the html, you should print the following: "Content-type: text/html\n\n".  Did you include that?
0
 
LVL 5

Expert Comment

by:icd
ID: 1829732
faster is quite right is stating that the Content-type has to be output but this would not explain why the file is not output.

The next most likely explaination is that the path to the file is wrong. The path you gave seems to be one relative to your web page root directory. This will not be the path if you (for example) telnet into the site. Assuming that your script is in the cgi-bin directory try changing the path to a relative path name, e.g.

$redopage="../olticket/jonr&d/redopage.html";

(or whatever is appropriate).

You can also put some diagnostics into your file. e.g.

open (REDOPAGE $redopage) || die "<HTML><HEAD><BODY>Cannot open file $redopage reason $!</BODY></HTML>\n";

(this should all be on one line).


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

604 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