Use exec function

Hello everybody,

I try Yii framework to create an administrative website. I actually encounter a problem to use the PHP function “exec” inside the Yii application context (It simply do not run the exec function). ???

Is there any specific security configuration to modify to allow it, I do not find it into the documentation ?

Note : Using the same apache server I've made a test.php page which succefully run my exec function, but not in my controller.php (probably Yii security context I think)

Any idea / suggestion ?

Thanks in advance.

Swann

hmm, Yii has no such security context thing to prevent you from using "exec". What is the command you try to run?

Firstly, thanks for your answer.

I try to run an "ssh" command (which execute a remote command on differents servers). But I do not think the problem come from the command itself because when i try to run a simple exec("whoiam"); i do not recieved any result (return var is empty).

I try to execute the same code into a test page (excluding Yii tools, but located in the same folder and with the same file permission) When I call it directly from the browser, then the test works.

I do not understand why it does not works when I run an exec inside a controller objet.

For information :

my controller definition :

class RSYController extends CController

{

[…] // Here some code for other actions, which works fine

public function actionServer()

{

// my command

$getServerStatusCommand = "whoiam";

// The execution

exec($getServerStatusCommand, $server_status);

//result to screen

$this->render('server',array('server_status'=>$server_status));

}

}

Is my request more clear ?

I think it should be “whoami” and if you set it as second parameter it returns an array:

array(1) { [0]=>  string(8) “www-data” }
… else you should do
$server_status =exec($getServerStatusCommand);

bye,

Giovanni.

Effectivly it is whoami and not whoiam. Whit this synthax it works perfeclty, so you was right it was my command which was wrong, my bad sorry. :-\

I've search and finally found the bug (into my ssh config file, and not in the php code).

My problem is solved, thanks a lot for help and really sorry for my mistake about exec problem and my command bug  ::)