Exit a Script Immediately

by Dec 7, 2009

Use the Exit statement if you run into a condition where a script should quit. The script breaks whenever you call exit from within your script. Add a number to Exit to set the error level (return code). The caller of your script can then check the automatic variable $LASTEXITCODE to see if the script ended prematurely and determine its exit code.

Twitter This Tip! ReTweet this Tip!