Ted_Fines_13095
Aug 05, 2013Nimbostratus
TMSH error handling / exit codes
How do I use error handling / exit code checking in TMSH scripts?
For example, tmsh::create may be used to create a SNAT. If however the SNAT already exists, the script stops. How do you just get a return code from a tmsh command like tmsh::create and have the script accordingly?
e.g. Like the below pseudocode would do. I use this specifically because I have a need to add additional origin IPs to a domain if it exists, but to create a domain if it does not exist.
proc script::run { } {
RESULT=tmsh::create ltm snat my.domain.com origins add \{ 10.1.2.3 \} translation 8.9.10.11
if (RESULT = 0) {
puts "Hey, it worked."
} else {
puts "It failed. Error code=$RESULT"
}
}
Thanks in advance.