Included in my thesis is to create an administration interface, in which an administrator can approve users whom have asked for access to use OpenNebula.
Upon approval the users should be added to OpenNebula (i.e. it corresponds
to the command oneadmin createuser username password
). (More information
of the interface (section 4.2).)
I am trying to perform this with an execution of a shell command in a PHP file. Why doesn't this work (below is just a specific example - not the general code that I am using)?
$execQuery = "/bin/su oneadmin postgres -c '/usr/bin/oneuser create test10 test10'";
shell_exec ($execQuery); //execute query in shell.
Nor does this work (even though I am logged in as oneadmin, when the script is executed by PHP):
shell_exec ("/usr/bin/oneuser create test10 test10");
It works when I type that command in the shell. I have tried to execute other shell commands through php and those work fine, so I wonder where the problem lies.
I have given the file /usr/bin/oneuser
rwx
rights for all users.
id
orsleep 10
as the command?shell_exec
returns the output as a string. Does theoneuser
command produce any output? Try printing out the return value instead of discarding it. Does the command produce any error output? If you runshell_exec("echo 1>&2 this is an error")
, where does the error message end up?