Apache not executing script!! help required soon


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Apache not executing script!! help required soon
# 1  
Old 05-25-2009
Apache not executing script!! help required soon

i need to know all possible reasons for apache not able to execute a command on server side script.
I have a cgi script that calls a shell script .This shell script calls a perl script which has commnad in it.
Ths command is not getting executed from gui.The return status of shell script is 256.
The command is of type:
`/path/xxx > /path/t.log`;
Here in the t.log log file i can see:
sh:xxx: permission denied
but the all scripts have 777 permission,
even command script has 777 permission.
But from terminal evrything is working fine.
Even other functions from the gui are working fine except this function.
# 2  
Old 05-25-2009
Have you check the /path owner and permision? Is it allow the apache httpd's owner to access and execute the file?
Some how, the file is allow for all user but the folder is not allow the other group or user to access.
# 3  
Old 05-25-2009
give the apache user a shell in /etc/passwd, su to apache-user and try to execute the script manually

don't forget to remove the shell afterwards
# 4  
Old 05-25-2009
how do i do that?can you please give me an example

Quote:
Originally Posted by tom_cmu
Have you check the /path owner and permision? Is it allow the apache httpd's owner to access and execute the file?
Some how, the file is allow for all user but the folder is not allow the other group or user to access.
all folders have 777 permissions..

Quote:
Originally Posted by funksen
give the apache user a shell in /etc/passwd, su to apache-user and try to execute the script manually

don't forget to remove the shell afterwards
how to do that?please give me an exmaple
# 5  
Old 05-25-2009
Quote:
Originally Posted by raksha.s
how to do that?please give me an exmaple
edit /etc/passwd, or use the command

Code:
usermod -s /bin/bash apache

su - apache

cd to the path the perl script is in

cd /path/

./perlscript.pl

see if it's executable,

then

Code:
usermod -s /sbin/nologin apache


perhaps you have to specify hardcoded variables in the script, depends on what you are doing with it, you don't want to destroy something I guess


apache username and path of /sbin/nologin may differ on your system
# 6  
Old 05-26-2009
Quote:
Originally Posted by funksen
edit /etc/passwd, or use the command

Code:
usermod -s /bin/bash apache

su - apache

cd to the path the perl script is in

cd /path/

./perlscript.pl

see if it's executable,

then

Code:
usermod -s /sbin/nologin apache

perhaps you have to specify hardcoded variables in the script, depends on what you are doing with it, you don't want to destroy something I guess


apache username and path of /sbin/nologin may differ on your system
yes,i did wat u said,It worked.But from browser the same cgi script is not working!!!!

Last edited by raksha.s; 05-26-2009 at 01:37 AM..
# 7  
Old 05-26-2009
Hi. raksha.s

To find the process owner. In solaris, it generally use 'ps -ef ' command to list all current process.
In other Unix system use "ps -aux" instead.
However, If your system has long list of process you can use "ps -ef | more" to watch it page by page.
I have a simple script for you to find who is the owner of the httpd process as below.
$ pgrep -f httpd | xargs -t -I {} ps -fp {} | cut -d" " -f1

The pgrep -f will fetch the httpds process id. The xargs prepare the output from pgrep as the agruments for ps command. The cut command with -d (delimiter) " " (space) give you the first column (user id) from PS command.

For the apache it is, for security, usually running by "nobody" to get the lowest privilege. So, that why I ask you to check the httpd owner.

About the cgi script, I hope you have already check that the second script that called by the first script is also permitted.

Hope you can find the break point soon.

Last edited by tom_cmu; 05-26-2009 at 07:30 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

PHP script that detects if auth is required or not on Apache Splunk

I am currently trying to do a PHP script that detects automatically if Apache Splunk authentication is required or not but I'm having a hard time since HTTP code 303 is always coming back, even if auth is required or not. Here is the script so far; <?php /** * Apache Splunk script to... (4 Replies)
Discussion started by: syrius
4 Replies

2. UNIX for Dummies Questions & Answers

Not able to get the required o/p from my script

Hi Experts, I have a script as below : # cat a.sh var=`mysql -usupport -p'testing' -e "select count(1) from db_test.sampletable;"` echo $var the output of this script is : count(1) 145039 Now i want to remove header from my o/p and modify somewhat like 145039 I have... (9 Replies)
Discussion started by: mukulverma2408
9 Replies

3. UNIX for Dummies Questions & Answers

Perl Script:how to find how many parameters are required to run the script

How to find how many parameters are required to run a Perl script? (1 Reply)
Discussion started by: Lakshman_Gupta
1 Replies

4. Shell Programming and Scripting

Script required

Hey All, I am seeking for the script which will do as follows, 1) Login on one Unix server "Server1" 2) Want to access other Unix server "Server2", and want to get the information as, on one go. df -k /tmp df -k / df -k "any file system" 3) Re-direct the output to "space.txt" on... (12 Replies)
Discussion started by: ravinderkodan88
12 Replies

5. Shell Programming and Scripting

Script invoked using "sh" is not executing. Urgent help required

Hi , I am new to shell scripting. I am using Linux for doing scripting. Below is my script, which takes 2 parameters as input. test.sh has the below: #!/bin/bash . $HOME/.profile gpg --yes --no-use-agent -r "$(eval echo \$$2_Var)" -e $1 1st parameter is command line... (7 Replies)
Discussion started by: rangarb
7 Replies

6. Shell Programming and Scripting

Help required to get a script

Hi Experts, I am very beginner in Bash Shell Scripting. Can anyone please guide me to create a script which should show the most busy file systems in sort basis as there are a lot of file systems on the server. I was told this task to be done by my IT lead and I must have to do this in... (3 Replies)
Discussion started by: naw_deepak
3 Replies

7. Shell Programming and Scripting

Getting required fields from a test file in required fromat in unix

My data is something like shown below. date1 date2 aaa bbbb ccccc date3 date4 dddd eeeeeee ffffffffff ggggg hh I want the output like this date1date2 aaa eeeeee I serached in the forum but didn't find the exact matching solution. Please help. (7 Replies)
Discussion started by: rdhanek
7 Replies

8. UNIX for Advanced & Expert Users

Help required in this script.

Hi Everyone, Please find below the script, I needed to understand step by step:confused:. Please If someone can help me out i will be very greatful:D. Please Guide me in a way which can help me out in figuring what this script doing on my server. ... (3 Replies)
Discussion started by: jojo123
3 Replies

9. UNIX for Advanced & Expert Users

Executing a shell script from windows;script present in unix

I need to execute a shell script kept in unix machine from windows. User id, password area available. For eg. There's a shell script wich moves all the logs kept in my home directory to a directory named LOGS. Now i need to get this done through windows; either using a batch file, or java... (4 Replies)
Discussion started by: rajneesh_kapoor
4 Replies

10. Shell Programming and Scripting

script required

The line is like this +abc+def+mgh+ddsdsd+sa i.e. words seperated by +. There is a plus in the beginning. i want to conver this line to abc, def, mgh, ddsdsd, sa please provide the logic in the form of a shell script Thanks in advance (13 Replies)
Discussion started by: skyineyes
13 Replies
Login or Register to Ask a Question