Unix programming

15 pts.
Tags:
Programming
Unix
When writing a shell script, how do you verify a command completes successfully?
1

Answer Wiki

Thanks. We'll let you know when a new response is added.
Hi,

Use :—

 #bash-x script.sh 
This will tell you each step of script execusion .

Also If we want to check , your script is executed properly .
# sh script.sh
# echo $?
0
Now if output is zero, it means script executed properly .
Other then zero value mean an error during execution .

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Brijesh
    Maybe like if [[ $? -ne 0 ]]; 
    then echo "Program failed"
    exit 2
    fi.
    14,450 pointsBadges:
    report
  • carlosdl
    Or simply this:

    if command ; then
        echo "Success"
    fi

    84,745 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: