PHP apache Korn script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
premtemp
Forum Newbie
Posts: 3
Joined: Sat Feb 02, 2008 8:02 am

PHP apache Korn script

Post 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 />";
?>
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: PHP apache Korn script

Post by Weirdan »

It's not clear why would you check email validity via shell script to start with.
premtemp
Forum Newbie
Posts: 3
Joined: Sat Feb 02, 2008 8:02 am

Re: PHP apache Korn script

Post 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
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: PHP apache Korn script

Post 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.
Post Reply