Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

cgi's won't execute

Posted on 2002-07-22
7
Medium Priority
?
253 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
Technology Partners: 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!

 
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 200 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.
Suggested Courses

963 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