LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 02-07-2004, 11:49 PM   #1
feetyouwell
Member
 
Registered: Dec 2003
Location: NC, US
Distribution: Novell Linux Eval (2.6.5)
Posts: 240

Rep: Reputation: 30
executing script via webpage through apache server


I have a problem here, i am trying to execute a simple shell script iva a webpage using <isindex> tag. All it is in the script besides echoing out the html stuff is a simply grep command. I am using grep to look into a file on the server to match certain patterns, and output the results to the html page. For example, the script is basically like this(for output):

#! /bin/sh
echo Content-TYPE: text/html
echo "<necessary html stuff>"
echo " .... same as above"
for i in $*
do
grep -i $i /some_dir/file_that's_looked_up | ./a_formatting_program
done
echo "<more html stuff>"

it's working fine on my old webserver, when i switch to apache, it's no longer working anymore. It's echoing out the html stuff, but it's finding nothing!!! Seems like the grep is taking affect at all. Any thoughts on it ???? Appreciate your help!
 
Old 02-08-2004, 09:34 AM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
Are the files accessable and executeable by the user that you are running apache as?
 
Old 02-08-2004, 12:55 PM   #3
feetyouwell
Member
 
Registered: Dec 2003
Location: NC, US
Distribution: Novell Linux Eval (2.6.5)
Posts: 240

Original Poster
Rep: Reputation: 30
yes, it's world readable.
 
Old 02-08-2004, 01:39 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
What about the formatting program?
 
Old 02-08-2004, 01:45 PM   #5
feetyouwell
Member
 
Registered: Dec 2003
Location: NC, US
Distribution: Novell Linux Eval (2.6.5)
Posts: 240

Original Poster
Rep: Reputation: 30
yes, it's world executable as well, it worked on the old webserver (not apache), but once i switch to apache, grep stops running
 
Old 02-08-2004, 01:56 PM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
Try changing the grep line to create an error log:
grep -i $i /some_dir/file_that's_looked_up 2>&1 > /tmp/grep.log

Ignore the formatting program just for testing - go you get anything in the grep.log file?

Another thought I just had is to use the full path to grep - eg:
/usr/bin/grep
 
Old 02-08-2004, 02:47 PM   #7
feetyouwell
Member
 
Registered: Dec 2003
Location: NC, US
Distribution: Novell Linux Eval (2.6.5)
Posts: 240

Original Poster
Rep: Reputation: 30
i tried that, the log file showed all the resutls, so i guess the problem is that it's "displaying" back to the brower.
 
Old 02-08-2004, 04:23 PM   #8
feetyouwell
Member
 
Registered: Dec 2003
Location: NC, US
Distribution: Novell Linux Eval (2.6.5)
Posts: 240

Original Poster
Rep: Reputation: 30
Thanx for all your help man, i finally figured out the problem.
the apache server is adding extra string to my env. variable, that's why grep is not finding anything
ex.

when exceuting:
/some_dir/course_srch?art[0-9]

the <isindex> is supposed to send art[0-9] to the env. variable $*

when going through apache, apache added "\" to make it look like

art\[0-9\]

that's why grep is not find anything. and it seems like any regular expression simbol i put in, apache will put \ in front of it, (must be a security thing), so i just added [0-9] to the search string within my shell script and everything seems to be working.
 
  


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
Executing an ELF 32 bit on an Apache server running Linux chrisrock79 Linux - Software 12 10-13-2005 02:12 PM
CGI File Not Executing on Apache Server kaplan71 Linux - Software 2 10-21-2004 08:12 AM
Apache executing Java Script linux_pioneer Solaris / OpenSolaris 2 08-26-2004 01:31 PM
executing shell script on apache nooodles Linux - General 1 06-29-2004 02:51 AM
Script is not executing in Apache!!! linux_child001 Linux - Newbie 1 06-22-2004 06:10 AM


All times are GMT -5. The time now is 04:12 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration