Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 06-28-2004, 10:43 AM   #1
LQ Newbie
Registered: May 2004
Location: Texas
Posts: 18

Rep: Reputation: 0
executing shell script on apache

i have an apache webserver running and i want to be able to execute these shell scripts from a web browsers. for now i have a script called test in the /var/www/html directory which simply contains

echo "testing"

this file is executable. on a client machine when i enter the ip addr of the webserver and the file name (htt[:/ i get the exact output as above. it just prints out the contents of the test file to the web browser than execute that file.

does anyone know how to fix this? it's probably really easy, but for me i'm a newb.

Old 06-29-2004, 02:51 AM   #2
Registered: Jun 2004
Location: colorado, USA
Distribution: slack, oBSD
Posts: 119

Rep: Reputation: 24

not sure if I completely understand your issue, but I have a couple ideas.

For one, in scripts executable via the client's web browser, use "print" in lieu of "echo." The first line tells the browser what to expect:
print "Content-type: text/html\n\n";
print "testing."
You need the content-type declaration before printing anything else to the browser, and the two newlines at the end of it are required. For actual pages, you'll want the HTML tags, but many browsers will still display the text without the proper stuff in place. You can bunch it all into one print statement if you like:
print "Content-type: text/html\n\n
<html><head><title>This page is dynamic HTML!</title></head>
zedmelon sure is a swell guy  ;)
Second, try relocating the file to your cgi-bin. I don't know if that's a universal requirement, but it makes sense from a security standpoint to compartmentalize script execution. All my HTML and web crap is completely self-taught, so with that in mind I just moved one of my scripts to another directory for grins, and my browser listed the file instead of executing it.

You should already have a cgi-bin, probably /var/www/cgi-bin, but if not, check to see if your httpd.conf mentions another place for a ScriptAlias:
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
If you have any virtual hosts running (if you don't know what that means, don't worry; you don't), then each virtual host has the potential for using a different cgi-bin, but still might not. If you're not running virtual hosts, that's the directory to use.

Also, "Location: <URL>" instead of the content type line will redirect to a new page, but it can't come after a content-type declaration.

Last edited by zedmelon; 06-29-2004 at 02:52 AM.


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
executing konsole from shell script Meriadoc Linux - Newbie 10 07-10-2009 09:08 AM
Executing a shell script command!! vishamr2000 Programming 4 08-15-2005 01:33 AM
verify if the same shell script is executing in background hicham007 Programming 2 08-07-2005 06:40 AM
Auto-Executing Shell Script on boot benrose111488 Linux - Software 5 12-18-2004 01:52 AM
executing a shell script from C llama_meme Programming 2 04-01-2002 10:10 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:43 AM.

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