Solved

cgi's won't execute

Posted on 2002-07-22
7
248 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
 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

 
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

624 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