Solved

Random 500 server error

Posted on 1997-05-30
20
164 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
[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
  • 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
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 

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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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 the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
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 …
The viewer will learn how to dynamically set the form action using jQuery.

734 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