premtemp Posted February 2, 2008 Share Posted February 2, 2008 Hello, I have a simple Korn shell script and I am trying to call it from PHP and it always return the error leg of the statement from the browser. However, if I execute the php script from the shell command prompt it work fine.. I tried exec, exec_shell but i get the same result.. Thanks in advance for any help. here is the code SHELL SCRIPT[prem.ksh] #!/bin/ksh # main runtime KEY=$1 echo $KEY EMAILTEST=`echo $KEY | /usr/local/bin/egrep -i [A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$ | wc -l ` if [[ $EMAILTEST -eq 0 ]]; then echo ERROR: The email address \"$KEY\" is not in a valid email form.. exit -1 else echo $EMAILTEST fi ------------------------- PHP SCRIPT<?php $command = '/home/pb0581/prem.ksh [email protected] '; $x = system($command,$output); echo "ret_error = ".$x; echo "<br />"; echo $output; echo "<br />"; ?> Link to comment https://forums.phpfreaks.com/topic/89053-executing-external-not-working/ Share on other sites More sharing options...
tapos Posted February 2, 2008 Share Posted February 2, 2008 I think this your permission problem. When you use shell scripting you r the root. But when u use the browser, that time u r not a root. Link to comment https://forums.phpfreaks.com/topic/89053-executing-external-not-working/#findComment-456108 Share on other sites More sharing options...
premtemp Posted February 2, 2008 Author Share Posted February 2, 2008 Thanks for your response and I will look into the permission. But It getting to the script and return a value. So after posting this question I change the shell script as show below and ran the PHP script from both the unix shell and the Web and it works. However, if I change it back to using the egrep it fails.. so it wierd...But I will look at permission but if it is permission I don't think it will executing the script Thanks # main runtime KEY=$1 echo $KEY if [[ $KEY = "[email protected]" ]]; then echo match else echo no match fi Link to comment https://forums.phpfreaks.com/topic/89053-executing-external-not-working/#findComment-456157 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.