I prefer to do my scripting from a windows box, using the old school "DOS" shell, or whatever the cool kids call it these days. This requires the 3PAR CLI to be installed. This way each 3par command's return code gets passed back to the DOS session for logic purposes.
Check out my sample script for doing D.O. in this sub forum for examples. The 3PAR Cli for Windows documentation is also helpful for listing all the possible environmental variables it can use, and how to create a secure encrypted password file, etc.
viewtopic.php?f=17&t=215