Jump to content

executing external not working


premtemp

Recommended Posts

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 prem.temp@companyy.com ';

$x = system($command,$output);

echo "ret_error = ".$x;

echo "<br />";

echo $output;

echo "<br />";

?>

 

Link to comment
Share on other sites

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 = "prem.temp@somecomapny.com" ]]; then

  echo match

else

  echo no match

fi

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.