LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 06-28-2004, 09:43 AM   #1
nooodles
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

#!/bin/bash
echo "testing"

this file is executable. on a client machine when i enter the ip addr of the webserver and the file name (htt[:/10.10.30.100/test) 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.

thanks!
-Anthony
 
Old 06-29-2004, 01:51 AM   #2
zedmelon
Member
 
Registered: Jun 2004
Location: colorado, USA
Distribution: slack, oBSD
Posts: 119

Rep: Reputation: 24
cgi-bin

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:
Code:
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:
Code:
print "Content-type: text/html\n\n
<html><head><title>This page is dynamic HTML!</title></head>
<body>
zedmelon sure is a swell guy  ;)
</body></html>"
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:
Code:
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 01:52 AM.
 
  


Reply



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 08:08 AM
Executing a shell script command!! vishamr2000 Programming 4 08-15-2005 12:33 AM
verify if the same shell script is executing in background hicham007 Programming 2 08-07-2005 05:40 AM
Auto-Executing Shell Script on boot benrose111488 Linux - Software 5 12-18-2004 12:52 AM
executing a shell script from C llama_meme Programming 2 04-01-2002 09:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:28 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
Open Source Consulting | Domain Registration