The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help required in this script. jojo123 UNIX for Advanced & Expert Users 3 05-20-2009 04:05 AM
Executing a shell script from windows;script present in unix rajneesh_kapoor UNIX for Advanced & Expert Users 4 05-08-2009 03:54 PM
Ksh Script help required... marconi Shell Programming and Scripting 2 07-03-2008 11:28 AM
Script required to get a required info from file. Pls. help me. ntgobinath Shell Programming and Scripting 2 05-31-2008 09:34 AM
Required Script shameeque Windows & DOS: Issues & Discussions 3 02-14-2007 04:19 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-25-2009
raksha.s raksha.s is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 20
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 (permalink)  
Old 05-25-2009
tom_cmu tom_cmu is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 19
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 (permalink)  
Old 05-25-2009
funksen funksen is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2006
Location: Austria/Vienna
Posts: 431
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 (permalink)  
Old 05-25-2009
raksha.s raksha.s is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 20
how do i do that?can you please give me an example

Quote:
Originally Posted by tom_cmu View Post
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 View Post
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 (permalink)  
Old 05-25-2009
funksen funksen is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2006
Location: Austria/Vienna
Posts: 431
Quote:
Originally Posted by raksha.s View Post
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 (permalink)  
Old 05-26-2009
raksha.s raksha.s is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 20
Quote:
Originally Posted by funksen View Post
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 (permalink)  
Old 05-26-2009
tom_cmu tom_cmu is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 19
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..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0