AbeFroman Posted August 20, 2007 Share Posted August 20, 2007 I have a bash script that authenticates accounts against Active Directory using the Kerberos "kinit" utility. Script works as expected from command line. (status return =0) (Linux FC6, Apache 2.2.4,PHP 5.1.6) When called with the PHP exec command from a web page it fails. (status return =1) Debug commands in the script show it is being called with exactly the same parameters from the command line and from php. Quote Link to comment https://forums.phpfreaks.com/topic/65886-solved-bash-script-fails-when-called-from-php-within-web-page/ Share on other sites More sharing options...
trq Posted August 21, 2007 Share Posted August 21, 2007 Its more than likely a permissions issue. Are you able to run this script as a normal user, or do you need to be root? Quote Link to comment https://forums.phpfreaks.com/topic/65886-solved-bash-script-fails-when-called-from-php-within-web-page/#findComment-329396 Share on other sites More sharing options...
Hypnos Posted August 21, 2007 Share Posted August 21, 2007 Did you try chowning it to the apache user? Did you try running the php script from the shell? Quote Link to comment https://forums.phpfreaks.com/topic/65886-solved-bash-script-fails-when-called-from-php-within-web-page/#findComment-329397 Share on other sites More sharing options...
AbeFroman Posted August 21, 2007 Author Share Posted August 21, 2007 I did a chown apache:apache on the script file. Same results as before. Status return from the script = 1 when called from PHP and =0 when called from the shell even though params are identical. I am using the root account. When I run the web page from the command line using "php" it aborts on the statement where I'm checking if the REQUEST_METHOD was a "POST" and nothing else executes after that. Is there an esay way around that? Quote Link to comment https://forums.phpfreaks.com/topic/65886-solved-bash-script-fails-when-called-from-php-within-web-page/#findComment-330399 Share on other sites More sharing options...
trq Posted August 21, 2007 Share Posted August 21, 2007 From the shell are you able to run this script as a normal user, or do you need to be root? Quote Link to comment https://forums.phpfreaks.com/topic/65886-solved-bash-script-fails-when-called-from-php-within-web-page/#findComment-330406 Share on other sites More sharing options...
AbeFroman Posted August 21, 2007 Author Share Posted August 21, 2007 Tried running it from a generic account. Failed with Status=1. Problem seems to be when script creates a temporary file of "expect" commands. Looks like it cannot create the file in whatever directory the httpd process is running the script. Fixed that by putting file in the /tmp directory. Now script works when run from command line under generic (non-privileged) account. However , PHP still gets status=1 back when running the script from within web page. Quote Link to comment https://forums.phpfreaks.com/topic/65886-solved-bash-script-fails-when-called-from-php-within-web-page/#findComment-330431 Share on other sites More sharing options...
AbeFroman Posted August 22, 2007 Author Share Posted August 22, 2007 Finally figured it out. On the PHP exec command I added "&>--log-file--" to capture output from the execution of the shell script. The shell script was unable to find the "kinit" utility in the /usr/kerberos/bin/ directory when executed from within Apache. I simply added the full path to the utility and all is well. Thanks for the suggestions above. Quote Link to comment https://forums.phpfreaks.com/topic/65886-solved-bash-script-fails-when-called-from-php-within-web-page/#findComment-330486 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.