Results 1 to 6 of 6

Thread: hook not working

  1. #1
    Member
    Join Date
    Feb 2007
    Posts
    11

    Default hook not working

    Whenever I try to run:
    Code:
    /usr/local/cpanel/bin/manage_hooks add script /var/cpanel/MyApp/foo_describe.php
    I get the error:
    Code:
    Hook not found.
    
    The add action requires that a module or script name is specified example:
            bin/manage_hooks add Module My::Module
    
    Options can also be manually specified using the following params --category, --event and --stage are defined, example:
            bin/manage_hooks add script /var/MyApp/hooks/something.pl --category=Whostmgr --event=Accounts::Create --stage=pre
    
    See --help for more information
    I'm following the docs directly, any ideas? The file does exist and I have created the appropriate describe code as well.

  2. #2
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    570

    Default Re: hook not working

    Hi atDev,

    What output do you get when you run
    Code:
    /var/cpanel/MyApp/foo_describe.php --describe
    foo_describe.php should print/echo a JSON structure. Does it?

    Regards,
    -DavidN
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Requests

  3. #3
    Member
    Join Date
    Feb 2007
    Posts
    11

    Default Re: hook not working

    Quote Originally Posted by cPanelDavidN View Post
    Hi atDev,

    What output do you get when you run
    Code:
    /var/cpanel/MyApp/foo_describe.php --describe
    foo_describe.php should print/echo a JSON structure. Does it?

    Regards,
    -DavidN
    I get:
    Error in argument 1, char 3: option not found

    File contents:
    Code:
    #!/usr/bin/php -q
    
    <?php
    $describe = array(
        array(
            'namespace' => 'Whostmgr',
            'function'  => 'Accounts::Create',
            'stage'     => 'post',
            'hook'      => '/var/cpanel/MyApp/foo_CreateInstance.php'
        )
    );
    
    if ( in_array('--describe', $argv) ) {
        print json_encode($describe);
        exit();
    }
    ?>

  4. #4
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    570

    Default Re: hook not working

    hmm, works fine for me?

    Code:
    [david:/var/cpanel/MyApp] $ ls -l
    total 4
    -rwxr-xr-x 1 root root 330 Jun  6 08:31 foo_describe.php
    [david:/var/cpanel/MyApp] $ cat /var/cpanel/MyApp/foo_describe.php 
    #!/usr/bin/php -q
    
    <?php
    $describe = array(
        array(
            'namespace' => 'Whostmgr',
            'function'  => 'Accounts::Create',
            'stage'     => 'post',
            'hook'      => '/var/cpanel/MyApp/foo_CreateInstance.php'
        )
    );
    
    if ( in_array('--describe', $argv) ) {
        print json_encode($describe);
        exit();
    }
    ?>
    [david:/var/cpanel/MyApp] $ /var/cpanel/MyApp/foo_describe.php --describe
    
    [{"namespace":"Whostmgr","function":"Accounts::Create","stage":"post","hook":"\/var\/cpanel\/MyApp\/foo_CreateInstance.php"}][david:/var/cpanel/MyApp] $ 
    [david:/var/cpanel/MyApp] $ /usr/bin/php -v
    PHP 5.2.17 (cgi) (built: Jun 16 2011 09:33:37)
    Copyright (c) 1997-2010 The PHP Group
    Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
    [david:/var/cpanel/MyApp] $
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Requests

  5. #5
    Member
    Join Date
    Feb 2007
    Posts
    11

    Default Re: hook not working

    Hm I had a tech look at it and they said:

    I've had a look and the issue is that PHP does not parse shell
    arguments the way you're attempting. The arguments apply to the PHP binary,
    not to the PHP script itself. The error printing to screen is displaying the
    only accepted flags to the PHP binary.

    Wonder why it works for you an not on our server?

  6. #6
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    570

    Default Re: hook not working

    check you ini settings related to argv/argc

    PHP: $argv - Manual
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Requests

Similar Threads

  1. whm hook?
    By bitter_ in forum cPanel Developers
    Replies: 3
    Last Post: 07-13-2010, 10:14 AM
  2. killacc hook
    By oflus in forum cPanel Developers
    Replies: 1
    Last Post: 05-13-2009, 09:46 AM
  3. Login Hook
    By IamRhodesy in forum cPanel Developers
    Replies: 1
    Last Post: 11-05-2008, 09:04 AM
  4. doaddpop hook?
    By dorris in forum cPanel & WHM Discussions
    Replies: 2
    Last Post: 04-16-2008, 05:32 AM
  5. newftpuser hook
    By rapidot in forum cPanel & WHM Discussions
    Replies: 15
    Last Post: 08-03-2007, 05:56 PM