Random 500 server error

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.
yanweiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

yanweiAuthor Commented:
Edited text of question
0
icdCommented:
Is it possible you have file locking problems where someone else is accessing a file at the same time as you?
0
yanweiAuthor Commented:
Edited text of question
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

yanweiAuthor Commented:
Adjusted points to 150
0
nquiogueCommented:
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
yanweiAuthor Commented:
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
pc012197Commented:
Try moving the "print Content-type"... to the very beginning of the script (right after #!/usr/local/bin/perl) and see what happens.
0
yanweiAuthor Commented:
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
pc012197Commented:
Hm. Have you looked at the server's error-logfile?

0
yanweiAuthor Commented:
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
nquiogueCommented:
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
yanweiAuthor Commented:
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
jdd2Commented:
Do you have other messages in the error logfile if you try
with the -w switch ? -Tw ? use strict ; ?
0
nquiogueCommented:
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
gracieCommented:
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
bron_aCommented:
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
yanweiAuthor Commented:
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
gabsiCommented:
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
yanweiAuthor Commented:
Dear Gabsi,
 This error does not occur everytime with the same data.
 thanks,
 Yanwei
0
stevenc317Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.

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.