Results 1 to 6 of 6

Thread: Cron::edit_line and "bad minute"

  1. #1
    Member
    Join Date
    May 2006
    Posts
    52

    Default Cron::edit_line and "bad minute"

    Query URL being generated:

    http://xx.xx.xx.xx:2086/xml-api/cpan...d=/usr/bin/php /home/path/to/script > /dev/null&day=*&hour=*&linekey=687e5a83695ba3eabaa2e29ace490b6d&minute=*/15&month=*&weekday=*

    This always returns the following error:

    [linekey] => 263470a91ddc5550c627fdd05ba2bfcd
    [status] => 0
    [statusmsg] => "-":1: bad minute
    errors in crontab file, can't install.

    Any ideas?

  2. #2
    Member
    Join Date
    May 2006
    Posts
    52

    Default Re: Cron::edit_line and "bad minute"

    OK, on further investigation using the Dumper tool, it seems that if the "command" contains a space it drops the rest of the argument(s). Any solution to this?

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

    Default Re: Cron::edit_line and "bad minute"

    I don't want to sound silly, but did you try encoding you URL query values?
    Code:
    command=/usr/bin/php+/home/path/to/script+>/dev/null
    
    or
    
    command=%2Fusr%2Fbin%2Fphp+%2Fhome%2Fpath%2Fto%2Fscript+%3E+%2Fdev%2Fnull
    Other than that, I noticed that your posted query URL is lacking "cpanel_xmlapi_apiversion=2" which is required for making API2 calls via XML-API. Additionally, I'd suggest using "cpanel_xmlapi_user" instead of just "user". This is not manditory, however you'll find problems if you call a function, say Ftp:addftp, where an input parameter key is "user". The result would be mangling of the first user/value pair. So, we have "cpanel_xmlapi_user" to clarify.

    Best 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

  4. #4
    Member
    Join Date
    May 2006
    Posts
    52

    Default Re: Cron::edit_line and "bad minute"

    Quote Originally Posted by cPanelDavidN View Post
    I don't want to sound silly, but did you try encoding you URL query values?
    Yep, I tried that, still no luck.

    Are you inferring I should add "+" in place of spaces for the command part of the API call?

    Other than that, I noticed that your posted query URL is lacking "cpanel_xmlapi_apiversion=2" which is required for making API2 calls via XML-API.
    The API documentation says it defaults to version 2, and the error response back is indicating it's using version 2, hence I haven't added this.

    Additionally, I'd suggest using "cpanel_xmlapi_user" instead of just "user". This is not manditory, however you'll find problems if you call a function, say Ftp:addftp, where an input parameter key is "user". The result would be mangling of the first user/value pair. So, we have "cpanel_xmlapi_user" to clarify.
    Makes sense, will update my scripts with that, thanks

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

    Default Re: Cron::edit_line and "bad minute"

    I tried it out on 11.28.83 and it appears to work fine for me.

    Below is my output from the list/add/list/edit/list command. Following that is my test scripts (which use the XML-API PHP client class)

    Code:
    [David-Pro:] $ php -f cron_listcron.php; php -f cron_add_line.php; php -f cron_listcron.php; php -f cron_edit_line.php; php -f cron_listcron.php 
    URL: https://10.1.1.1:2087/xml-api/cpanel
    DATA: cpanel_xmlapi_user=dave&cpanel_xmlapi_module=Cron&cpanel_xmlapi_func=listcron&cpanel_xmlapi_apiversion=2
    Authentication Header: Authorization: Basic -hashed-
    
    
    RESPONSE:
     <?xml version="1.0" ?>
      <cpanelresult>
        <apiversion>2</apiversion>
        <data>
          <count>1</count>
        </data>
        <event>
          <result>1</result>
        </event>
        <func>listcron</func>
        <module>Cron</module>
      </cpanelresult>
    
    SimpleXML var_dump:
    SimpleXMLElement Object
    (
        [apiversion] => 2
        [data] => SimpleXMLElement Object
            (
                [count] => 1
            )
    
        [event] => SimpleXMLElement Object
            (
                [result] => 1
            )
    
        [func] => listcron
        [module] => Cron
    )
    
    URL: https://10.1.1.1:2087/xml-api/cpanel
    DATA: command=%2Fbin%2Fls+%2Fhome%2Fdave+%3E%3E+%2Ftmp%2Fls.log&day=%2A&hour=10&minute=00&month=%2A&weekday=%2A&cpanel_xmlapi_user=dave&cpanel_xmlapi_module=Cron&cpanel_xmlapi_func=add_line&cpanel_xmlapi_apiversion=2
    Authentication Header: Authorization: Basic -hashed-
    
    
    RESPONSE:
     <?xml version="1.0" ?>
      <cpanelresult>
        <apiversion>2</apiversion>
        <data>
          <linekey>37df09d7a25ba2dd756b757944a05865</linekey>
          <status>1</status>
          <statusmsg>crontab installed</statusmsg>
        </data>
        <event>
          <result>1</result>
        </event>
        <func>add_line</func>
        <module>Cron</module>
      </cpanelresult>
    
    SimpleXML var_dump:
    SimpleXMLElement Object
    (
        [apiversion] => 2
        [data] => SimpleXMLElement Object
            (
                [linekey] => 37df09d7a25ba2dd756b757944a05865
                [status] => 1
                [statusmsg] => crontab installed
            )
    
        [event] => SimpleXMLElement Object
            (
                [result] => 1
            )
    
        [func] => add_line
        [module] => Cron
    )
    
    URL: https://10.1.1.1:2087/xml-api/cpanel
    DATA: cpanel_xmlapi_user=dave&cpanel_xmlapi_module=Cron&cpanel_xmlapi_func=listcron&cpanel_xmlapi_apiversion=2
    Authentication Header: Authorization: Basic -hashed-
    
    
    RESPONSE:
     <?xml version="1.0" ?>
      <cpanelresult>
        <apiversion>2</apiversion>
        <data>
          <command>/bin/ls /home/dave &gt;&gt; /tmp/ls.log</command>
          <command_htmlsafe>/bin/ls /home/dave &amp;gt;&amp;gt; /tmp/ls.log</command_htmlsafe>
          <count>1</count>
          <day>*</day>
          <hour>10</hour>
          <linekey>37df09d7a25ba2dd756b757944a05865</linekey>
          <minute>00</minute>
          <month>*</month>
          <weekday>*</weekday>
        </data>
        <data>
          <count>2</count>
        </data>
        <event>
          <result>1</result>
        </event>
        <func>listcron</func>
        <module>Cron</module>
      </cpanelresult>
    
    SimpleXML var_dump:
    SimpleXMLElement Object
    (
        [apiversion] => 2
        [data] => Array
            (
                [0] => SimpleXMLElement Object
                    (
                        [command] => /bin/ls /home/dave >> /tmp/ls.log
                        [command_htmlsafe] => /bin/ls /home/dave &gt;&gt; /tmp/ls.log
                        [count] => 1
                        [day] => *
                        [hour] => 10
                        [linekey] => 37df09d7a25ba2dd756b757944a05865
                        [minute] => 00
                        [month] => *
                        [weekday] => *
                    )
    
                [1] => SimpleXMLElement Object
                    (
                        [count] => 2
                    )
    
            )
    
        [event] => SimpleXMLElement Object
            (
                [result] => 1
            )
    
        [func] => listcron
        [module] => Cron
    )
    
    URL: https://10.1.1.1:2087/xml-api/cpanel
    DATA: linekey=37df09d7a25ba2dd756b757944a05865&command=%2Fbin%2Fls+%2Fhome%2Fdave+%3E%3E+%2Ftmp%2Fls.log&day=%2A&hour=10&minute=%2A%2F15&month=%2A&weekday=%2A&cpanel_xmlapi_user=dave&cpanel_xmlapi_module=Cron&cpanel_xmlapi_func=edit_line&cpanel_xmlapi_apiversion=2
    Authentication Header: Authorization: Basic -hashed-
    
    
    RESPONSE:
     <?xml version="1.0" ?>
      <cpanelresult>
        <apiversion>2</apiversion>
        <data>
          <linekey>32fbf9c75996d20e2628ef8b6018e189</linekey>
          <status>1</status>
          <statusmsg>crontab installed</statusmsg>
        </data>
        <event>
          <result>1</result>
        </event>
        <func>edit_line</func>
        <module>Cron</module>
      </cpanelresult>
    
    SimpleXML var_dump:
    SimpleXMLElement Object
    (
        [apiversion] => 2
        [data] => SimpleXMLElement Object
            (
                [linekey] => 32fbf9c75996d20e2628ef8b6018e189
                [status] => 1
                [statusmsg] => crontab installed
            )
    
        [event] => SimpleXMLElement Object
            (
                [result] => 1
            )
    
        [func] => edit_line
        [module] => Cron
    )
    
    URL: https://10.1.1.1:2087/xml-api/cpanel
    DATA: cpanel_xmlapi_user=dave&cpanel_xmlapi_module=Cron&cpanel_xmlapi_func=listcron&cpanel_xmlapi_apiversion=2
    Authentication Header: Authorization: Basic -hashed-
    
    
    RESPONSE:
     <?xml version="1.0" ?>
      <cpanelresult>
        <apiversion>2</apiversion>
        <data>
          <command>/bin/ls /home/dave &gt;&gt; /tmp/ls.log</command>
          <command_htmlsafe>/bin/ls /home/dave &amp;gt;&amp;gt; /tmp/ls.log</command_htmlsafe>
          <count>1</count>
          <day>*</day>
          <hour>10</hour>
          <linekey>32fbf9c75996d20e2628ef8b6018e189</linekey>
          <minute>*/15</minute>
          <month>*</month>
          <weekday>*</weekday>
        </data>
        <data>
          <count>2</count>
        </data>
        <event>
          <result>1</result>
        </event>
        <func>listcron</func>
        <module>Cron</module>
      </cpanelresult>
    
    SimpleXML var_dump:
    SimpleXMLElement Object
    (
        [apiversion] => 2
        [data] => Array
            (
                [0] => SimpleXMLElement Object
                    (
                        [command] => /bin/ls /home/dave >> /tmp/ls.log
                        [command_htmlsafe] => /bin/ls /home/dave &gt;&gt; /tmp/ls.log
                        [count] => 1
                        [day] => *
                        [hour] => 10
                        [linekey] => 32fbf9c75996d20e2628ef8b6018e189
                        [minute] => */15
                        [month] => *
                        [weekday] => *
                    )
    
                [1] => SimpleXMLElement Object
                    (
                        [count] => 2
                    )
    
            )
    
        [event] => SimpleXMLElement Object
            (
                [result] => 1
            )
    
        [func] => listcron
        [module] => Cron
    )
    
    [David-Pro:] $
    # cron_listcron.php
    PHP Code:
    <?php
    include("xmlapi.php");

    $ip "10.1.1.1";
    $root_pass "s3cr3t!";
    $cpuser 'dave';


    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth("root",$root_pass);

    $xmlapi->set_debug(1);

    $m 'Cron';
    $f 'listcron';
    $args = array();

    $xmlapi->api2_query($cpuser$m$f$args);
    ?>
    # cron_add_line.php
    PHP Code:
    <?php
    include("xmlapi.php");

    $ip "10.1.1.1";
    $root_pass "s3cr3t!";
    $cpuser 'dave';


    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth("root",$root_pass);

    $xmlapi->set_debug(1);

    $m 'Cron';
    $f 'add_line';
    $args = array(
        
    'command' => '/bin/ls /home/dave >> /tmp/ls.log',
        
    'day'      => '*',
        
    'hour'      => '10',
        
    'minute'  => '00',
        
    'month'      => '*',
        
    'weekday' => '*',
    );

    $xmlapi->api2_query($cpuser$m$f$args);
    ?>
    # cron_edit_line.php
    PHP Code:
    <?php
    include("xmlapi.php");

    $ip "10.1.1.1";
    $root_pass "s3cr3t!";
    $cpuser 'dave';


    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth("root",$root_pass);

    $xmlapi->set_debug(1);

    $m 'Cron';
    $f 'edit_line';
    $args = array(
        
    'linekey' => '37df09d7a25ba2dd756b757944a05865',
        
    'command' => '/bin/ls /home/dave >> /tmp/ls.log',
        
    'day'      => '*',
        
    'hour'      => '10',
        
    'minute'  => '*/15',
        
    'month'      => '*',
        
    'weekday' => '*',
    );

    $xmlapi->api2_query($cpuser$m$f$args);
    ?>
    And to clarify, about the pluses (+), I was simply referring to general url parameter encoding, nothing crazy

    Your absolutely right about the default behave of the XML-API query parsing. If it notices that it is a cPanel API tag and the request does not contain the 'cpanel_xmlapi_apiversion' key/value pair, it will assume API2. I just prefer to be explicit. It's up to you

    Best 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

  6. #6
    Member
    Join Date
    May 2006
    Posts
    52

    Default Re: Cron::edit_line and "bad minute"

    David,

    Why reinvent the wheel when I can use your XMLAPI class huh?

    I modified my code to workaround your class, and everything is working great now. Thank you very much for your assistance.

Similar Threads

  1. iPhone - "bad certificate" errors trying to receive email
    By BigLebowski in forum E-mail Discussions
    Replies: 1
    Last Post: 08-13-2008, 01:33 PM
  2. rkhunter : I have some bad "System tools" ?
    By Nikoms in forum cPanel & WHM Discussions
    Replies: 4
    Last Post: 12-03-2007, 03:59 AM
  3. Adding IP Failed "Ignoring bad line in /etc/wwwacct.conf"
    By coderoyal in forum cPanel & WHM Discussions
    Replies: 3
    Last Post: 03-20-2007, 07:10 AM
  4. Is this "sniffer" line something bad?
    By Metro2 in forum cPanel & WHM Discussions
    Replies: 2
    Last Post: 07-26-2006, 10:13 AM