AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.

 View Only
  • 1.  EXIT STATUS OF THE COMMAND

    Posted Wed May 21, 2008 03:26 AM

    Originally posted by: SGLFORUM


    Is it possible to capture the command status in AIX 5.3 (i.e. whether the command executed successfully).

    I need to develop a script where I have to execute the command only if the previous commands exit status is 0.

    Kindly guide how to capture the exit status of the command.


  • 2.  Re: EXIT STATUS OF THE COMMAND

    Posted Wed May 21, 2008 04:35 AM

    Originally posted by: tony.evans


    This is really dependant on the shell you're using. In ksh (AIX's default shell) the variable $? contains the return code value of the previous command.

    Message was edited by: tony.evans


  • 3.  Re: EXIT STATUS OF THE COMMAND

    Posted Wed May 21, 2008 11:57 PM

    Originally posted by: SGLFORUM


    Thanks for the reply.

    Can I suppress the error message returning from the command?


  • 4.  Re: EXIT STATUS OF THE COMMAND

    Posted Thu May 22, 2008 11:06 AM

    Originally posted by: orphy


    ls /etc/security
    ls: /etc/security: The file access permissions do not allow the specified action.
    echo $?
    2
    ls /etc/security 2> /dev/null
    echo $?
    2
    Orphy