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.

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. 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
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
  4. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    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.
     
Loading...

Share This Page