Hello,
I need help with a resturn value of custom hook module. The module code is as follows,
The hook code is below,( the hook is python fun.py
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.
I need help with a resturn value of custom hook module. The module code is as follows,
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
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,
Code:
[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: 100
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.
Last edited by a moderator: