Solved

cgi's won't execute

Posted on 2002-07-22
7
246 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
[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
  • 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Fine Tune your automatic Updates for Ubuntu / Debian
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

739 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