[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Problem to running  CGI script

Posted on 2004-10-22
13
Medium Priority
?
176 Views
Last Modified: 2013-11-18
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
Comment
Question by:lazii
[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
  • 5
  • 4
13 Comments
 
LVL 4

Expert Comment

by:TomDavidson
ID: 12381646
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
 

Author Comment

by:lazii
ID: 12381768
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
 
LVL 15

Expert Comment

by:periwinkle
ID: 12382211
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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 

Author Comment

by:lazii
ID: 12382398
I change what u tell me.......but still have asame problem
0
 
LVL 15

Expert Comment

by:periwinkle
ID: 12382460
as mentioned, overrides may not be possible by the .htaccess file - can you change the httpd.conf file?
0
 

Author Comment

by:lazii
ID: 12382702
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
 
LVL 15

Expert Comment

by:periwinkle
ID: 12382847
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
 

Author Comment

by:lazii
ID: 12383803
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
 

Author Comment

by:lazii
ID: 12386880
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
 
LVL 15

Accepted Solution

by:
periwinkle earned 2000 total points
ID: 12392339
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

Industry Leaders: 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!

Question has a verified solution.

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

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
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 arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
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…

649 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