Solved

mrtg rrd 14all.cgi apache php? Everything is working except apache php aint displaying CGI scripts!!!!!

Posted on 2003-11-24
4
549 Views
Last Modified: 2013-12-23
hi anyone! how do u get php 4.3 and Apache 2.0.48 to display cgi scripts on FreeBSD 5.1? ive tried everything from Options +ExecCGI in the directories but when i try to get it from the website i get the error server Misconfiguration (ERROR 500!!!). on checking the error logs it says Incomplete ending of script which cant be because when i test the .cgi script it generates the necessary HTML telling me that MRTG and RRD are working but i cant get apache to display on FreeBSD but it has worked on WindowsXP. Can anyone help please!!!!???????????
0
Comment
Question by:KevoZam
[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
  • 2
4 Comments
 
LVL 1

Expert Comment

by:mbekker
ID: 9810718
Hi KevoZam,

Could it be possible that the lines are CR/LF terminated? I see the script is working fine on Windows, but not on Unix. Unix prefers LF terminated lines.

If this is the case you could strip the CarriageReturns from the end of lines with:

1. sed 's/^V^M$//' file.cgi >file2.cgi
2. vi file.cfg
    :%s/^V^M$//
    :wq

The ^ before ^V and ^M means <Ctrl>.

Another way is to FTP the script in ASCII mode from/to Unix/Windows.

Good luck!
0
 
LVL 62

Expert Comment

by:gheist
ID: 9813652
how do you test ???
correct test is:
unset PATH LD_LIBRARY_PATH
export METHOD=GET # and more cgi variables
cd /var/www/cgi-bin
./script.cgi
---
you need this first line for script
#!/usr/bin/perl -w

HTTP prefers <CR><LF> i.e \0x13\0x16 instead of simple \n ( which in Windows case turns into <CR><LF>)

0
 

Author Comment

by:KevoZam
ID: 9829614
thank you Gheist and Mbekker but im kinda new to this could you give me a detailed way to do what your saying?? I test the 14all.cgi script by doing the following in FreeBSD and Windows and the result is the same. The script is called mrtg.cgi so i open a command prompt and get to the cgi-bin where it is saved and say:
                              perl mrtg.cgi
this generates HTML code in the console window telling MRTG and RRD are working. Apache on Windows displayed it but on FreeBSD i get the 500 error and on going to the error log i get message "PREMATURE END OF SCRIPT HEADER". So how do i implement the changes your saying please?????????? Thanks
0
 
LVL 62

Accepted Solution

by:
gheist earned 90 total points
ID: 9830250
I guess your script starts with

print("Content-type: text/html\n\n);

Correct way is
print("Contetnt-type: text/html\012\015\012\015");

no special symbols, all you see is to be typed

i.e.
Windows expands \n in manner you expect, but UNIX and MacOS not
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Let’s list some of the technologies that enable smooth teleworking. 
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

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