Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Plugin development : qx command, wrong exit value

Discussion in 'cPanel Developers' started by anjalimetclouds, May 17, 2015.

  1. anjalimetclouds

    Joined:
    Mar 4, 2015
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi,

    In my plugin, I would like to run a command capture its exit value. Given below is my code.

    $result = qx{yum check-update};
    $exitcode = $?;


    There is updates in server so the exit value should be 100. But the exit value is 25600 here. Don't know how this happens. Please help me to solve this issue.

    Thanks
     
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,895
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. anjalimetclouds

    Joined:
    Mar 4, 2015
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi,

    The command is working and $? is returning value. But the problem is that when I run the command and get the exit code manually, it returns 100 and when I try to run the same command in my plugin the return value is 25600. I am using centos.

    Do you have any idea to solve this issue? Please help me.

    Thank you
     
  4. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,895
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    You will likely receive more input on this type of question on a website such as StackOverflow. The forums here are primarily intended for specific questions related to the cPanel/WHM software itself, rather than general development questions.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,563
    Likes Received:
    43
    Trophy Points:
    308
    cPanel Access Level:
    Root Administrator
    Please read the information about $? in the perlvar documentation (http://perldoc.perl.org/perlvar.html). The value in $? is not the same exit value as obtained on the shell command line. To obtain the exit value you need to perform a bitwise shift on it. The documentation I linked to provide some examples.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice