Solved

cgi's won't execute

Posted on 2002-07-22
7
237 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now