Jump to content

Problems with execute command


jevylux

Recommended Posts

Hi, I have a strange problem using the exec command.

I have the following php code :

<?php

error_reporting(E_ALL);

ini_set('display_errors','On');

 

$accountBase = "HORAIREMOBILE";

$primaryUser = "DUM";

$secondaryUser = "DUM";

$result = exec(escapeshellcmd("/home/evidian/utils/getAccount ".escapeshellarg($accountBase)." ".escapeshellarg($primaryUser)." ".escapeshellarg($secondaryUser)),$output,$return_val);

echo $result;

?>

 

When I execute the command from the CLI, with any user, it just works fine, and shows my the result (basically a JSON formated output).

However, when I call the code frome the apache server, it simply returns nothing.

 

Could anybody help me with this issue ?

 

Link to comment
https://forums.phpfreaks.com/topic/253952-problems-with-execute-command/
Share on other sites

The permission are 0777, so everyone has read, write and execute rights.

 

When I start the php using the command line interface it works.

I tried executing a

su wwwrun

and then execute the command with

php /srv/www/htdocs/getAccount.php  (which is the source code I posted) and it works.

 

At first I also thought that it looks like a rights problem, but why does it work using cli ?

 

Your command may be malformed. Save it into a variable and echo it to see what it actually looks like:

 

$cmd = escapeshellcmd("/home/evidian/utils/getAccount ".escapeshellarg($accountBase)." ".escapeshellarg($primaryUser)." ".escapeshellarg($secondaryUser));
echo $cmd;
$result = exec($cmd);
echo $result;

 

Aslo, make sure you have error reporting enabled.

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.