We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Random 500 server error

yanwei
yanwei asked
on
Medium Priority
202 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.
Comment
Watch Question

Author

Commented:
Edited text of question
icd

Commented:
Is it possible you have file locking problems where someone else is accessing a file at the same time as you?

Author

Commented:
Edited text of question

Author

Commented:
Adjusted points to 150

Commented:
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.

Author

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";

 



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

Author

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.

Commented:
Hm. Have you looked at the server's error-logfile?

Author

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"

Commented:
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

Author

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.

Commented:
Do you have other messages in the error logfile if you try
with the -w switch ? -Tw ? use strict ; ?

Commented:
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);

Commented:
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";
                       

Commented:
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.

Author

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.
 
 

Commented:
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

Author

Commented:
Dear Gabsi,
 This error does not occur everytime with the same data.
 thanks,
 Yanwei
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.