How to retrun value from custom hooks cpanel uapi module
Hello,
I need help with a resturn value of custom hook module. The module code is as follows,
[CODE=perl]sub foo {
my ( $args, $result, $response ) = @_;
my ( $arg1, $arg2 ) = $args->get( 'arg1', 'arg2' );
my $feature = 'cfoo_foo';
if ( !main::hasfeature($feature) ) {
$result->error( '_ERROR_FEATURE', $feature );
return;
}
if ( $Cpanel::CPDATA{'DEMO'} ) {
$result->error( '_ERROR_DEMO_MODE', $feature );
return;
}
my $success=0;
if ($arg1 eq "foo"){
$success=1;
}
else{
$success=0;
}
if ($success) {
$result->data();
return 1;
}
else {
return 0;
}
}
The hook code is below,( the hook is python fun.py [CODE=python]runcmd="some-command-out-put-as-json" da=os.popen(runcmd).read().rstrip() return_value['status'>=1 return_value['status_msg'>=runcmd return_value['msg'>=da result=json.loads(json.dumps(return_value)) return(result)
The debug result is as follows,
As you can see the "result" . Doesnt have any value. The hook works fine. Please help what am I missing I checked the documentation of custom modules in cpanel and result management option. But I am unable to return the results.
The hook code is below,( the hook is python fun.py [CODE=python]runcmd="some-command-out-put-as-json" da=os.popen(runcmd).read().rstrip() return_value['status'>=1 return_value['status_msg'>=runcmd return_value['msg'>=da result=json.loads(json.dumps(return_value)) return(result)
The debug result is as follows,
[2020-11-29 12:55:51 +0530] info [cpanel] ---debug_hooks---
[2020-11-29 12:55:51 +0530] info [cpanel] msg: Beginning execution of script hook.
[2020-11-29 12:55:51 +0530] info [cpanel] stage: pre
[2020-11-29 12:55:51 +0530] info [cpanel] result: 0
[2020-11-29 12:55:51 +0530] info [cpanel] point: main
[2020-11-29 12:55:51 +0530] info [cpanel] id: 4ac88d48-ec5e-4088-82d7-32580762b169
[2020-11-29 12:55:51 +0530] info [cpanel] hook: /usr/local/foo/cphooks/fun.py
[2020-11-29 12:55:51 +0530] info [cpanel] escalateprivs: 1
[2020-11-29 12:55:51 +0530] info [cpanel] weight: 100
[2020-11-29 12:55:51 +0530] info [cpanel] HOOK INFO: hook /usr/local/foo/cphooks/fun.py did not output any data
[2020-11-29 12:55:51 +0530] info [cpanel] ---debug_hooks---
[2020-11-29 12:55:51 +0530] info [cpanel] msg: Finished execution of script hook.
[2020-11-29 12:55:51 +0530] info [cpanel] stage: pre
[2020-11-29 12:55:51 +0530] info [cpanel] result: 1
[2020-11-29 12:55:51 +0530] info [cpanel] point: main
[2020-11-29 12:55:51 +0530] info [cpanel] id: 4ac88d48-ec5e-4088-82d7-32580762b169
[2020-11-29 12:55:51 +0530] info [cpanel] hook: /usr/local/foo/cphooks/fun.py
[2020-11-29 12:55:51 +0530] info [cpanel] escalateprivs: 1
[2020-11-29 12:55:51 +0530] info [cpanel] weight: 100As you can see the "result" . Doesnt have any value. The hook works fine. Please help what am I missing I checked the documentation of custom modules in cpanel and result management option. But I am unable to return the results.
-
Hey there! I'm not sure that I have enough information to properly answer this for you based on the details provided. Can you let me know specifically what you're looking to do with the API/hook system? Once I know that I may be able to get you better details. 0 -
Hey there! I'm not sure that I have enough information to properly answer this for you based on the details provided. Can you let me know specifically what you're looking to do with the API/hook system? Once I know that I may be able to get you better details.
I need to get return result from the api hook. I already given sample code and the steps.0 -
@syslint - I had our development team look at this yesterday and they let me know there wasn't enough details provided for us to get you more information. I'm also not seeing any familiar API calls from cPanel in the example listed. For this situation, it might be better to put in a ticket with our team so we can access the server with the issue and run the scripts on our side. 0
Please sign in to leave a comment.
Comments
3 comments