Solved

Random 500 server error

Posted on 1997-05-30
20
162 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!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Ned Perl Snippet to Read Files in Directory 5 69
Sed question 2 84
AWS CLI - Instances, Volumes & Tagging 2 92
Can I exclude specific directory with icacle command? 3 40
Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

785 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