Solved

Random 500 server error

Posted on 1997-05-30
20
163 Views
Last Modified: 2013-12-25
I am writing a web based submission tool. Now I have a problem that I use extactly the same data to make a submission, sometime it can pass through, some it can not. My perl scripts have no syntax error.I am sure it will print out "Content-type: html/text\n\n" at first line. I have checked the faq about 500 server error. No information explain my problem. The most tricky part is that once the submistion failed, you use "reload" button of netscape and repost the data, it can pass through, but if you use "back" button and submit the form again. It still failed. I am using perl5.002 and ncsa httpd1.5.2a. I found also sometime
my scripts generated core file.
0
Comment
Question by:yanwei
  • 9
  • 3
  • 2
  • +6
20 Comments
 

Author Comment

by:yanwei
ID: 1828136
Edited text of question
0
 
LVL 5

Expert Comment

by:icd
ID: 1828137
Is it possible you have file locking problems where someone else is accessing a file at the same time as you?
0
 

Author Comment

by:yanwei
ID: 1828138
Edited text of question
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:yanwei
ID: 1828139
Adjusted points to 150
0
 

Expert Comment

by:nquiogue
ID: 1828140
Could you post at least the skeleton of the script?
Server errors in the use of CGI usually result due to a premature
ending of script headers.
0
 

Author Comment

by:yanwei
ID: 1828141
The skeleton of the scripts is:

scripts.pl
---------------------------------------------------------------
#!/usr/local/bin/perl
$|=1;
use File::Basename;

..
some globe varible setting
like $cgidir
..

require "$cgidir/cgi-lib.pl";
require "$cgidir/Utilities.pl"; # Contains a lot of Utilites
                                # subroutines

ReadParse();

..
read some dictionary data
which are all ascii files
..

  print "Content-type: text/html\n\n";
  print "<HEAD>\n";
  $sectionName = &SectionName($sec);
  print "<TITLE>$sectionName $depid $basedOn</TITLE>\n";
  print "</HEAD>\n";
  print "<BODY BGCOLOR=#FFFFFF TEXT=#000000>\n";
 
&verifyInfo;  # Involved some transactions to sybase


  print "<FORM METHOD=POST          ACTION=\"http://$hserver/cgi-bin/scripts.pl\">";
  print "<INPUT type=hidden name=sec value=$sec>\n";
  print "<INPUT type=hidden name=depid value=$depid>\n";
  print "<INPUT type=hidden name=sc2 value=$sc2>\n";
  print "<INPUT type=hidden name=mod value=S>\n";

..

 print the contents of FORM, this part call a script which
have about 1000 subroutine

..

print "</FORM>\n";
print "</BODY>\n";

 



0
 
LVL 3

Expert Comment

by:pc012197
ID: 1828142
Try moving the "print Content-type"... to the very beginning of the script (right after #!/usr/local/bin/perl) and see what happens.
0
 

Author Comment

by:yanwei
ID: 1828143
I tried to print "print Content-type" right after
#!/usr/local/bin/perl
It still doesnot work.
This only works fine for sometime, and 500 server error appear
again.
Sometime I found if I reboot machine. The time of 500 server
error happens is greatly reduced. The disk which my scripts is
running on is contantly mounted.

0
 
LVL 3

Expert Comment

by:pc012197
ID: 1828144
Hm. Have you looked at the server's error-logfile?

0
 

Author Comment

by:yanwei
ID: 1828145
Yes, I have looked the error log file. There, it only has
"[Mon Jun  2 16:28:02 1997] HTTPd: malformed header from script /usr/local/etc/httpd/scrips.pl"
0
 

Expert Comment

by:nquiogue
ID: 1828146
It sometimes work and sometimes not?  And the problem is a
malformed header?
This is groping in the dark but use \r\n instead of \n so
Content-type: text/html\r\n\r\n
0
 

Author Comment

by:yanwei
ID: 1828147
Hi nquiogue,
 Thank for the reply.It does sometimes work and sometimes not.
In the error log of server, it said malformed header.
 I tried change \n to \r\n. It still does not work.

0
 

Expert Comment

by:jdd2
ID: 1828148
Do you have other messages in the error logfile if you try
with the -w switch ? -Tw ? use strict ; ?
0
 

Expert Comment

by:nquiogue
ID: 1828149
Firstly, I'd suggest running the script standalone using an interactive session as opposed to running under the server.

Secondly, this problem may have resulted with Perl's output buffering wherein you need to flush the buffers.  I'd suggest the following code:
local ($oldbar) = $|;
$cfh = select (STDOUT);
$| = 1;
#
# print your HTTP headers here
#
$| = $oldbar;
select ($cfh);
0
 

Expert Comment

by:gracie
ID: 1828150
Did you try:

..

print "Content-type: text/html\n\n";

print "<HEAD>\n";
$sectionName = &SectionName($sec);
print "<TITLE>$sectionName $depid $basedOn</TITLE>\n";
print "</HEAD>\n";
print "<BODY BGCOLOR=#FFFFFF TEXT=#000000>\n";
                       
0
 

Expert Comment

by:bron_a
ID: 1828151
500 Error (malformed script header)
The 'malformed script header' error means that the header of your CGI script is not correct.
add slash after the line #!/usr/local/bin/perl so it will be:
#!/usr/local/bin/perl/
Also, a server misconfiguration is possible, so only one user can run Perl, and when Perl is 'busy' you get this error.

0
 

Author Comment

by:yanwei
ID: 1828152
Dear All,
 Thanks for all your help. I used recompile perl5.004. Everything
is working fine. So the problem is seem a bug of perl5.002.
 Thanks again for all your time and efforts.
 
 
0
 
LVL 1

Expert Comment

by:gabsi
ID: 1828153
You have Error 500 when your program (cgi) exits with an error code (return code # 0).
It happens when your program abort for an execution error (called compilation error for perl).
Does this error occurs every time with the same data?

T.GABSI
0
 

Author Comment

by:yanwei
ID: 1828154
Dear Gabsi,
 This error does not occur everytime with the same data.
 thanks,
 Yanwei
0
 
LVL 1

Accepted Solution

by:
stevenc317 earned 150 total points
ID: 1828155
Try this...

1. upload your file to your cgi-bin directory
2. cd to the correct directory (for me it is www/cgi-bin)
3. run the file (e.g. file.pl)
4. read what it says, it will show you what your errors are and at what line they are on.
5. open MS notepad (if using windows)
6. fix your errors
7. go to #1

steven
webmaster of Steven's Web Page

FREE STUFF FOR YOUR WEB PAGE!!!
http://www.html.tou.com
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

820 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