Solved

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

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help with VLAN issue 6 58
Filter IP range with PowerShell 1 41
Need some help with Cisco 3750 switch configuration 8 29
Cisco switch suggestion 5 47
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
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…

776 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