LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-26-2005, 12:23 AM   #1
jkt2000
LQ Newbie
 
Registered: Aug 2004
Location: na
Distribution: RH9.0
Posts: 9

Rep: Reputation: 0
CGI-script problem on Apache2


Hi

Iím trying to setup a simple CGI script on my newly installed Apache2 server.


t1.cgi:
----------------------------
#!/bin/sh
echo Content-type: text/html
echo
echo Hello World


index.html:
----------------------------
<HTML>
<BODY>
start
<FORM ACTION="/cgi-bin/t1.cgi" METHOD="POST">
stop
</BODY>
</HTML>




My cgi-script (t1.cgi) is placed in /var/www/cgi-bin/

I added ďScriptAlias /cgi/bin/ /var/www/cgi-bin/Ē to the Apache conf file.


Whenever I type http://127.0.0.1/cgi-bin/t1.cgi in my browser, I get the expected output:

Hello World

Whenever I type http://127.0.0.1/index.html in my browser, I only get :

start
stop

It seems that the cgi-script never gets invoked.


Iím using Mandrake 10.1 and Apache2-2.0.50.

Any help will be appreciated.

Thanks
Jones
 
Old 01-26-2005, 02:03 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,666

Rep: Reputation: 1818Reputation: 1818Reputation: 1818Reputation: 1818Reputation: 1818Reputation: 1818Reputation: 1818Reputation: 1818Reputation: 1818Reputation: 1818Reputation: 1818
Don't you have to put a button or something inseide the <form> to execute the cgi.
Try this inside index.html:
Code:
<form action=.....>
<input type="submit" value="run">
</form>
 
Old 01-28-2005, 03:13 AM   #3
jkt2000
LQ Newbie
 
Registered: Aug 2004
Location: na
Distribution: RH9.0
Posts: 9

Original Poster
Rep: Reputation: 0
Hi Bathory,

Thanks for your suggestion. It works fine - I'm able invoke the cgi-script that way.

But my goal is to increment a counter each time my homepage has a hit so the cgi-script would have to be invoked automatically.

I have been playing around in the meantime. Even the exec command

<!--#exec cmd="/bin/date" -->

doesn't seem to work.

Do I need particular modules loaded by Apache to run cgi-scripts ? Or maybe something to do with permissions....

Thanks
Jones
 
Old 01-28-2005, 04:38 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,666

Rep: Reputation: 1818Reputation: 1818Reputation: 1818Reputation: 1818Reputation: 1818Reputation: 1818Reputation: 1818Reputation: 1818Reputation: 1818Reputation: 1818Reputation: 1818
If you want to this you need to use SSI (server side includes). Take a look at you apache httpd.conf to see what you need to change in order to achieve this.
Then use something like the following in your .shtml page:
Code:
<!--#include file="path/to/t1.cgi" -->
Regards
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
CGI With Apache2 karthik85nitt Linux - Newbie 2 07-15-2005 04:11 AM
Problem excuting cgi script in OpenBSD gani *BSD 3 05-26-2005 06:40 AM
problem apache2 CGI python MoinMoin (wiki) brasschaat Linux - Software 1 08-11-2004 08:26 AM
Apache cgi-script problem palanisaravanan Linux - General 6 02-07-2004 09:41 AM
Apache CGI Problem : Browser not running script Zaknafien Linux - Software 3 12-31-2003 01:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration