The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

hook not working

Discussion in 'cPanel Developers' started by atDev, Apr 13, 2012.

  1. atDev

    atDev Member

    Joined:
    Feb 15, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    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. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    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
     
  3. atDev

    atDev Member

    Joined:
    Feb 15, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    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. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    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] $
    
     
  5. atDev

    atDev Member

    Joined:
    Feb 15, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    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. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page