CMD_API_EXEC - User command execution is not enabled

sonson

New member
Joined
Mar 8, 2016
Messages
2
Hi all,
I'm using DirectAdmin version 1.45.0.
I follow instruction here ... http://www.directadmin.com/features.php?id=657 and
I wanted to run my own script via DA API located in /usr/local/directadmin/scripts/myscript/helloworld.sh

Here're permission I have for it...
-rwxr-xr-x 1 diradmin diradmin 41 Mar 9 10:29 /usr/local/directadmin/scripts/myscript/helloworld.sh

---- This is the error output ----
Array ( [error] => 1 [text] => Unable To Execute Your Command [details] => User command execution is not enabled )

Can any one advise how to solve this issue?
Thanks so much.

---- I added "allow_user_exec=1" into is my DA config ----
cat /usr/local/directadmin/conf/directadmin.conf | grep exec
allow_user_exec=1

---- This is my code to test the feature ----
include 'httpsocket.php';

$sock = new HTTPSocket;
$servers = array(
'IP' => array('admin','password')
);

foreach($servers as $server => $credentials) {

$sock->connect($server,2222);
$sock->set_login($credentials[0],$credentials[1]);

$sock->query('/CMD_API_EXEC',
array(
'command' => '/usr/local/directadmin/scripts/myscript/helloworld.sh',
'options' => ""
));
$result = $sock->fetch_parsed_body();

print_r($result);
}

---- This is helloworld.sh ---
#!/bin/sh

echo "The sun is starting to rise..."
 
Hello,

---- I added "allow_user_exec=1" into is my DA config ----
cat /usr/local/directadmin/conf/directadmin.conf | grep exec
allow_user_exec=1

Make sure you've got empty line after allow_user_exec=1

and better check with:

Code:
/usr/local/directadmin/directadmin c | grep ^allow_user_exec=
 
Thanks for your advise.
I added a new line into .conf and this setting worked.
However,
I met a strange error as below
Array ( [error] => 1 [text] => command cannot be found with your privileges [details] => /usr/local/directadmin/scripts/ [#53] => [#48] => [#48k/hello] => [#95world_sh] => )

I think that the long location caused this error.
Then I tried to move the script into shorted location: /usr/local/directadmin/
and IT WORKED PERFECTLY.

Thanks again!
 
I guess the error appeared due to wrong permissions of the directory /usr/local/directadmin/scripts/myscript/
 
Back
Top