jevylux Posted December 28, 2011 Share Posted December 28, 2011 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/253952-problems-with-execute-command/ Share on other sites More sharing options...
trq Posted December 28, 2011 Share Posted December 28, 2011 What are the permissions on /home/evidian/utils/getAccount ? Quote Link to comment https://forums.phpfreaks.com/topic/253952-problems-with-execute-command/#findComment-1301964 Share on other sites More sharing options...
jevylux Posted December 28, 2011 Author Share Posted December 28, 2011 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/253952-problems-with-execute-command/#findComment-1302002 Share on other sites More sharing options...
trq Posted December 28, 2011 Share Posted December 28, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/253952-problems-with-execute-command/#findComment-1302010 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.