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 [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

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.