• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

Problem to running CGI script

Hi
I am using fedora core1 and i also install apache web server on my machine. I place my website in /var/www/HTML and place my CGI script in /var/www/cgi-bin and everything working properly. But now i want to run my CGI script from other directory whatever i like. I change my HTML document and place my CGI script in other directory. I also change  /usr/local/apache/conf/httpd.conf
as
Addhandler cgi-script .cgi
options Indexes FollowSymLinks Multiviews ExecCGI
and my CGI script is with .cgi extension.
NOw my problem is my CGI is executing but giving some garbage value. Can u tell me whats wrong.Please reply me ASAP.
0
lazii
Asked:
lazii
  • 5
  • 4
1 Solution
 
TomDavidsonCommented:
Is your script giving an error? what's in the error log?

Try a very simple "hello world" script and see if that works, then you'll know if it's a configuration problem or a script problem.

If the script does not execute at all try looking at your ScriptAlias directive & the associated <Directory> block in httpd.conf
0
 
laziiAuthor Commented:
My script is executing. Like i design a registration page and script will take input from my page and write it a file for me and give customer a confirmation message. When i run it from cgi-bin directory its working properly and returning confirmation message to client browser but when i place my cgi-script in different directory then it returning some garbage value then some c coding and confirmation message as not a browsing style like a C coding.

Note: I write my script in C.
0
 
periwinkleCommented:
I would suspect that your web hosting is set up to only allow CGI scripts in the cgi-bin directory.  It's possible as well that you will not be able to override this with an .htaccess handler.

Try placing the following in your base directory:

<Limit GET POST>
order allow,deny
allow from all
</Limit>

I can't remember off the top of my head, but I beleive that these directives may need to go in a <directory> container, like:

<Directory /full/path/to/your/cgi-bin>
<Limit GET POST>
order allow,deny
allow from all
</Limit>
</Directory>
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!

 
laziiAuthor Commented:
I change what u tell me.......but still have asame problem
0
 
periwinkleCommented:
as mentioned, overrides may not be possible by the .htaccess file - can you change the httpd.conf file?
0
 
laziiAuthor Commented:
i write a simple script as
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html> <head>
<title>Example of a Forms page</title>
</head>

<body>
<h1>Forms Page 1</h1>
This page is an example of a forms page with a submit button. This is the
first of 2 forms pages. Both pages call the same script. How does the
script know which page has been used?
<p>
<form action="/cgi-bin/test2.cgi" method="post">
A text field <input type="TEXT" name="text1" size="24">
<p>
Some radio buttons. Select one<br>
Button 1 <input type="RADIO" name="radio" value=1 checked>
Button 2 <input type="RADIO" name="radio" value=2 >
Button 3 <input type="RADIO" name="radio" value=3 >
Button 4 <input type="RADIO" name="radio" value=4 >
<p>
<input type="RESET" value="Reset">
<input type="SUBMIT" value="Submit" name="form1">
</form>
</body> </html>

When i place test2.cgi in cgi-bin directory then it give me the value what i want but when i place it in different folder it gives me some garbage result.


what configuration i need to change in httpd.conf file  



0
 
periwinkleCommented:
That's correct.  If your server isn't set up to allow you to run CGI programs in directories outside of the cgi-bin, you'll get the CGI file rendered as text, instead of executing the code.

You need to locate your virtualhost entry, and add:

<Directory /full/path/to/your/cgi-bin>
<Limit GET POST>
order allow,deny
allow from all
</Limit>
</Directory>
0
 
laziiAuthor Commented:
probably u r right.  You  mean to change  this tag

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /www/docs/dummy-host.example.com
    ServerName dummy-host.example.com
    ErrorLog logs/dummy-host.example.com-error_log
    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>

or what.......if it is not..............i already write

 <Directory "/usr/local/apache/cgi-bin">
        AllowOverride None
        Options ExecCGI
        Order allow,deny
        Allow from all
        <Limit GET POST>
        order allow,deny
        allow from all
        </limit>
    </Directory>
 on my http.conf but afterthat still same problem
0
 
laziiAuthor Commented:
My CGI script executing and returning some test message on my browser........which is some garbage and some of my script codding......but when it come from cgi-bin then it gives a message in my browser that i write in my script for show when my script is runing properly
0
 
periwinkleCommented:
Your CGI script is a C program, correct?  Then the 'garbage' is the text rendition of the binary file.

What directory does your html files reside in?  That's the directory that you need to allow get and post;  if it is /www/docs/dummy-host.example.com, then:

<Directory "/www/docs/dummy-host.example.com">
        AllowOverride None
        Options ExecCGI
        Order allow,deny
        Allow from all
        <Limit GET POST>
        order allow,deny
        allow from all
        </limit>
</Directory>

BTW, AllowOverride None is what disables the use of the .htaccess file .
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now