When I run an exec
command in my php script, it is not giving any output but return value is 0
Background : I am trying to implement AS2 communication functionality using AS2Secure PHP code. When I am trying to send message to partner after signing and encrypting. But at the time of encrypting , it is not encrypting , we are sending only signed message.
Here is the exec
command function:
openssl smime -encrypt -in "C:\Users\Maggy\AppData\Local\Temp\as2A5B3.tmp" -out "C:\Users\Maggy\AppData\Local\Temp\as2B18B.tmp" -des3 "D:\as2secure_code_build-0.9.0\partners\maggy\clientcertificate.pem"
I ran the the same command in the command line and it is successfully giving output.
Here is the PHP code:
public static function exec($command, $return_output = false){
$output = array();
$return_var = 0;
try{
AS2Log::info(false, 'This is AS2Adapter File and IN EXEC FUNCTION CALLED'.$command);
// AS2Log::info(false, 'INPUT DATA as FOLLOWS'.file_get_contents($input));
exec($command , $output, $return_var);
// proc_open($command , $output, $return_var);
// passthru ("$command , 2>&1");
AS2Log::info(false, 'This is AS2Adapter File and IN EXEC FUNCTION EXECUTED and Result will
be ~~~~~~~~~~~~~~~~~~~~~');
AS2Log::info(false, 'This is AS2Adapter File and IN EXEC FUNCTION COMPLETED
SUCCESSFULLY'.$output[0]);
$line = (isset($output[0])?$output[0]:'Unexpected error in command line : ' . $command);
if ($return_var) throw new Exception($line, (int)$return_var);
}
catch(Exception $e){
throw $e;
}
AS2Log::info(false, 'This is RETURN OUTPUT LOOKS LIKE : '.file_get_contents($output));
AS2Log::info(false, 'This is RETURN VAR LOOKS LIKE : '.file_get_contents($return_var));
if ($return_output){
return $output;
AS2Log::info(false, 'This is AS2Adapter File and FINAL OUTPUT LOOKS LIKE : '.$output);
}
else
return $return_var;
}
Can you please help me resolve this issue?
I have tried shell_exec
and it is giving the same result.
I have tried the passthru
command but it didn’t give any result.
I am trying to do the signed and encrypted the message but it is only signing the message, not encrypting.