Solved

cgi's won't execute

Posted on 2002-07-22
7
243 Views
Last Modified: 2013-11-18
pls help.

The virtual domain has a virthost section in httpd.conf as follows:
<VirtualHost www.mydom.org>
   ServerAdmin webmaster@mydom.org
   DocumentRoot /home/www/mydom
   ServerName www.mydom.org
   <Directory />
    AllowOverride All
    Options FollowSymlinks Multiviews
    Order allow,deny
    Allow from all
   </Directory>
   ScriptAlias /cgi-bin/  /home/www/mydom/cgi-bin/
   <Directory /home/www/mydom/cgi-bin>
    AllowOverride All
    Options ExecCGI Includes
    Order allow,deny
    Allow from all
   </Directory>
   ErrorLog logs/mydom-error.log
   CustomLog logs/mydom-access.log common
</VirtualHost>


Yet, when I place a simple script such as
#!/usr/bin/perl
print "test";

Then I get internal server errors

I have tested it with all kinds of permissions; 755 and 777, but I still can't get it to execute.

Pls help.

Thanks
0
Comment
Question by:psimation
  • 4
  • 3
7 Comments
 
LVL 15

Expert Comment

by:samri
ID: 7169321
psimation,

You need to have you cgi scripts to send a proper http header.

Please could try the following;

#!/usr/bin/perl
print "Content-type:text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<title>My Title</title>\n
print "<body>\n";
print "test";
print "</body>\n";
print "</html>\n";


----
The most important part is
print "Content-type:text/html\n\n";

This is to tell the browser that the subsequent data will by of text/html type.

Please visit http://httpd.apache.org/docs/howto/cgi.html for much detail informatio on how to get CGI to work with Apache.

Hope the information is useful.

cheers.
0
 
LVL 17

Author Comment

by:psimation
ID: 7169464
Thanks, but it still does the same:
Malformed headers ...
script executes fine from command line though...
0
 
LVL 17

Author Comment

by:psimation
ID: 7169487
Thanks, but it still does the same:
Malformed headers ...
script executes fine from command line though...
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 15

Expert Comment

by:samri
ID: 7169712
Psimation.

Could you try replacing the config for vhost with this one;
ScriptAlias /cgi-bin/  /home/www/mydom/cgi-bin/

<Directory /home/www/mydom/cgi-bin>
   AllowOverride None
   Options None
   Order allow,deny
   Allow from all
</Directory>

Also look at Apache FAQ:
http://httpd.apache.org/docs/misc/FAQ.html#premature-script-headers
Also check the logfile (error_log) for any hints.
0
 
LVL 15

Accepted Solution

by:
samri earned 50 total points
ID: 7169724
Psimation,

hey. did you copy-paste my code.  Watch there is a missing quote (");  This one might work.  And try to flush all the buffer by $|=1;

#!/usr/bin/perl

$|=1;

print "Content-type:text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<title>My Title</title>\n";
print "<body>\n";
print "test";
print "</body>\n";
print "</html>\n";

cheers.
0
 
LVL 17

Author Comment

by:psimation
ID: 7171832
Ta
Damn headers.....
0
 
LVL 15

Expert Comment

by:samri
ID: 7171960
psimation,

If you are looking into developing CGI using perl, take a look at CGI.pm module (try "perldoc CGI" for some information).  It is actually a collection of modules for CGI manipulation.  Quite neat.

there is some examples too.

cheers.
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

Suggested Solutions

Title # Comments Views Activity
How to use question mark (?) in filename with html 25 93
Using sort and uniq to pare down large syslog 6 70
LogmeIn using Linux Ubuntu 16.04 6 103
asp Google Map 2 55
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Fine Tune your automatic Updates for Ubuntu / Debian
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

680 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