Solved

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

Posted on 2003-11-24
4
553 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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

For many of us, the  holiday season kindles the natural urge to give back to our friends, family members and communities. While it's easy for friends to notice the impact of such deeds, understanding the contributions of businesses and enterprises i…
Most of the applications these days are on Cloud. Cloud is ubiquitous with many service providers in the market. Since it has many benefits such as cost reduction, software updates, remote access, disaster recovery and much more.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Suggested Courses
Course of the Month6 days, 15 hours left to enroll

622 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