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

 

Link to comment
Share on other sites

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.

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.