Forum Discussion
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.
1 Reply
- uni
Altocumulus
Check the TCL "catch" command (http://wiki.tcl.tk/902). It is also discussed in the context of an iRule here https://devcentral.f5.com/articles/irules-101-07-catch, but it is a TCL command, not an iRule specific one.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com