[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Apache + cgi file, Internal server error, Premature end of scripts!

Posted on 2007-03-28
8
Medium Priority
?
1,520 Views
Last Modified: 2013-12-25
I have Apache 2.x, PHP 5.x installed in Linux server. The application has PHP files in the document root and 2 .cgi files (upload.cgi and progress.cgi) in the apache's cgi-bin directory. The upload.cgi takes care of uploading the file from the client to the server and the progress.cgi displays the progress bar of how much % of data is being transferred. So, basically the application is a mixture of PHP and Perl (since PHP doesn't handle the raw POST data)! Now, everything works fine and great!!

Problem is in the production environment. They have Apache 1.3 and PHP 5.x installed in Linux server. Small images less than say 500 KBytes works just fine. If the image is > 500 KByte, the progress bar works till 99% and upload.cgi reports "An internal server occurred". The apache error log says: "Premature end of scripts at header.cgi". This happens for 1MB image as well as 4.5MB image file but not for the < 500 KB image files!

I checked the max_upload_time, upload limit, etc., everything is okay. I wonder why this problem occurs only if the file size is bigger!

Please advise.
0
Comment
Question by:ldbkutty
[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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 39

Expert Comment

by:Adam314
ID: 18808682
Have you looked at the error log?  What is the error reported?
0
 
LVL 32

Author Comment

by:ldbkutty
ID: 18808947
"Premature end of script headers at header.cgi"
0
 
LVL 39

Expert Comment

by:Adam314
ID: 18809911
Try putting this at the top of your script:
use CGI::Carp qw(fatalsToBrowser);
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 51

Expert Comment

by:ahoffmann
ID: 18835160
when/where is your header.cgi used?
0
 
LVL 15

Expert Comment

by:samri
ID: 18849341
hi ldbkutty,

the problem appears when the file size exceed 500kb.  I had the impression that this is something to do with the PHP configuration, or the script setting, or maybe the server configuration -- check for how the data is transferred to the server -- either via POST of GET method.

you may also want to look at the server error_log file for some indication of the error.  if this is something to do with size limit, then obviously the error would register there.

Some other discussion that may be useful to get some hint -- there was just too much information posted that I could not paraphrase -- http://gallery.menalto.com/node/14870


cheers.
0
 
LVL 32

Accepted Solution

by:
ldbkutty earned 1500 total points
ID: 18887787
Problem was that I was using Windows editor and uploaded the changes of .cgi in Linux server!! I read somewhere to open and save the file in "vi" deleting the spaces in the first lines.

Everything works fine now! Thanks for your time.
0
 
LVL 15

Expert Comment

by:samri
ID: 18888418
aha.... that must be something to do with how dos/windows and unix did to the EOL (end of line) marker.  Somehow, transferring file between these two systems may give (myself) nightmare sometime.

I think there is a command called dos2unix and unix2dos that you could use to convert the file --- ie, if you edit the file in windows, and ftp that to unix, try running "dos2unix file.cgi", vice-versa.

cheers
0
 
LVL 39

Expert Comment

by:Adam314
ID: 18889836
Yes, the problem was caused by line endings.  Windows will use CR-LF as line ending, while unix uses only LF.
So your first line:
#!/usr/bin/perl<CR><LF>

Since unix considered LF to be the end of line, it was looking for /usr/bin/perl<CR> to execute your script, which doesn't exist.

If you upload the files using FTP in ASCII mode, that will solve the problem.  Or if you can't do that, if you put a space at the end of the line, that will solve the problem also (well, it won't get rid of the windows line endings, but unix will at least use the right program), like so:
#!/usr/bin/perl <space>

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

649 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