472,782 Members | 1,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,782 software developers and data experts.

difficulty in accessing perl program through a html page

Hi,

I am new to perl and was trying to write a perl program witha UI.
i.e. I have written a html form which invokes a perl program to execute and to print back the data selected in the form.

When i enter details into the html form and click on the submittal button, it throws an error saying
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, www@ophidian and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


--------------------------------------------------------------------------------

Apache/2.0.55 HP-UX_Apache-based_Web_Server (Unix) DAV/2 Server at ophidian.india.hp.com Port 8080 "

Below is the code of both the html and the perl script it calls.
Expand|Select|Wrap|Line Numbers
  1. html:
  2. <title>FORM 1</title>
  3. <html>
  4. <form method="POST" 
  5. action="http://ophidian.india.hp.com:8080/tools/newpro.pl">
  6. <p>
  7. <p>
  8. <table border=5 cellpadding=1 cellspacing=1><center>
  9. <tr>
  10. <th colspan=2>Submittal Management Tool</th>
  11. </tr>
  12. <tr>
  13. <td align=left><b>Release:</b></td>
  14. <td align=center>
  15. <select name ="release" size=4>
  16. <option>0706
  17. <option>0709
  18. <option>0712
  19. <option>0803
  20. <option>0809
  21. </select>
  22. </td>
  23. </tr>
  24.  
  25. <tr><td></td><td><center>
  26. <input type="reset" value="Clear">
  27. <input type="submit" value="Submit">
  28. </center></td></tr>
  29. </table>
  30. </center>
  31. </form>
  32. </html>
  33.  

Perl:
Expand|Select|Wrap|Line Numbers
  1. #!/opt/perl/bin/perl
  2.  
  3.  
  4. # The following accepts the data from the form and splits it into its component parts
  5.  
  6.  
  7.  
  8.         read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
  9.  
  10.         @pairs = split(/&/, $buffer);
  11.  
  12.         foreach $pair (@pairs)
  13.         {
  14.                 ($name, $value) = split(/=/, $pair);
  15.                 $value =~ tr/+/ /;
  16.                 $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  17.                 $FORM{$name} = $value;
  18.         }
  19. print "<p>";
  20. print "<p>";
  21. print " u selecte rel: $FORM{Release}<p>";
  22. exit(0);
  23.  

Could anyone please tell me why i am getting this error?
Please help!
Jul 22 '08 #1
2 1644
KevinADC
4,059 Expert 2GB
You need to print an HTTP header before any other output. The simplest way is:

Expand|Select|Wrap|Line Numbers
  1. print "Content-type: text/html\n\n";

Here it is added to your code:

Expand|Select|Wrap|Line Numbers
  1. #!/opt/perl/bin/perl
  2. print "Content-type: text/html\n\n";
  3.  
  4. # The following accepts the data from the form and splits it into its component parts
  5.  
  6.  
  7.  
  8.         read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
  9.  
  10.         @pairs = split(/&/, $buffer);
  11.  
  12.         foreach $pair (@pairs)
  13.         {
  14.                 ($name, $value) = split(/=/, $pair);
  15.                 $value =~ tr/+/ /;
  16.                 $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  17.                 $FORM{$name} = $value;
  18.         }
  19. print "<p>";
  20. print "<p>";
  21. print " u selecte rel: $FORM{Release}<p>";
  22. exit(0);
  23.  
Try again and see if that gets your above code working.

But you want to stop on this path you have taken. If you are serious about wanting to write perl based CGI scripts you should use the CGI module that comes with all standard distributions of perl.

http://perldoc.perl.org/CGI.html
Jul 22 '08 #2
spyka
10
ya egxactly...header is missing thas why its giving
that error....
Sep 14 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: MJL | last post by:
Suppose you have a perl program that is called by a web page to generate another web page. The program is written to load data from a text file on the server and make certain substitutions in the...
2
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # suppose you want to fetch a webpage. from urllib import urlopen print urlopen('http://xahlee.org/Periodic_dosage_dir/_p2/russell-lecture.html').read() #...
41
by: Xah Lee | last post by:
here's another interesting algorithmic exercise, again from part of a larger program in the previous series. Here's the original Perl documentation: =pod merge($pairings) takes a list of...
4
by: Gary | last post by:
I am calling a perl script that writes a WEB page - Plain and simple except that the perl script also writes out some PHP processing. All works fine when I just create an html file of the program...
0
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
22
by: owlice | last post by:
Greetings! I thought I'd add a little something to a web site, a "tip of the week," and wanted it automated so that if I get hit by a truck (or, more likely, am forgetful), the tip is updated...
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.