Page 1 of 1

PHP apache Korn script

Posted: Sat Feb 02, 2008 8:11 am
by premtemp
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]

Code: Select all

#!/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

Code: Select all

<?php
$command = '/home/pb0581/prem.ksh prem.temp@companyy.com ';
$x = system($command,$output);
echo "ret_error = ".$x;
echo "<br />";
echo $output;
echo "<br />";
?>

Re: PHP apache Korn script

Posted: Sat Feb 02, 2008 10:28 am
by Weirdan
It's not clear why would you check email validity via shell script to start with.

Re: PHP apache Korn script

Posted: Sat Feb 02, 2008 11:12 am
by premtemp
agree. but it it part of a bigger project and another user is coding the shell part. Just wanted to understand the problem. if I modify the shell script to have the code below and run the PHP program from the web it works so when does it not work with the egrep command

Thanks for your help

Code: Select all

echo $KEY
 if [[ $KEY = "prem.temp@companyy.com" ]]; then
  echo match
 else
  echo no match
 fi

Re: PHP apache Korn script

Posted: Sat Feb 02, 2008 8:07 pm
by Weirdan
Please use

Code: Select all

tags when posting code. You can add =language (

Code: Select all

,

Code: Select all

) to have it syntax highlighted. Your post has been edited to reflect how we'd like it to be marked up.