AIX

AIX

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


#Power
#Power
#Operatingsystems
#Servers
 View Only
  • 1.  validate the command

    Posted 06/14/08 08:15 AM

    Originally posted by: SGLFORUM


    Hi,

    Is there any way to validate the command in AIX 5.3 before executing the command?

    Thanks,

    Message was edited by: SGLFORUM
    #AIX-Forum


  • 2.  Re: validate the command

    Posted 06/16/08 05:05 AM

    Originally posted by: grukrz1


    which command?

    script?
    man ksh

    script you can validate using -n switch for ksh:
    -n
    Reads commands and checks them for syntax errors, but does not
    execute them. This flag is ignored for interactive shells.
    #AIX-Forum


  • 3.  Re: validate the command

    Posted 07/14/08 05:53 AM

    Originally posted by: SGLFORUM


    For example,

    When I enter "ls" in my ksh shell, then output is displayed. Whereas, if I enter "ls -4" (which is a wrong argument) an error message is displayed.

    I dont want to display the default error message in my shell script, if the input command is wrong. Instead, I need to print my own error message.
    #AIX-Forum


  • 4.  Re: validate the command

    Posted 07/14/08 10:33 AM

    Originally posted by: hdkutz


    Hmm,
    what about
    <snip>
    command 1>/dev/null 2>&1
    if $? != 0
    then
    echo "command has error: here stands my message"
    else
    echo "command looks ok"
    fi
    #AIX-Forum