sys icall script
sys icall script(1) BIG-IP TMSH Manual sys icall script(1)
NAME
script - Manage a Tcl script used by handlers during execution on the BIG-IP(r) system.
MODULE
sys icall
SYNTAX
Manage the script component within the sys icall module using the syntax shown in the following sections.
CREATE/MODIFY/EDIT
create script [name]
modify script [name]
edit script [name]
options:
definition
description [string]
events [add | delete | modify | replace-all-with] {
[event name] {
contexts [add | delete | modify | replace-all-with] {
[context name]
}
}
}
mv script [ [ [source-name] [destination-name] ] |
[ [name] to-folder [folder-name] ] |
[ [name...name] to-folder [folder-name] ] ]
options:
to-folder
DISPLAY
list script
list script [name]
DELETE
delete script [name]
Note: You must remove all references to the icall script before deletion.
DESCRIPTION
You can use this script component to manage Tcl scripts which are used by event handlers upon execution.
Caution: if you add a handler to a shared configuration on a set of BIG-IP appliances, then care must be used in making
changes to configuration items. A handler's script which makes config changes on more than one device may cause
inconsistencies that must be manually resolved.
EXAMPLES
create script my_script1
Create a new icall script item called "my_script1". Upon pressing enter, the user will enter the text editor in order to
edit the Tcl script. Note that this configuration item may only be modified while in the edit view.
mv script /Common/my_script to-folder /Common/my_folder
Moves an icall script named my_script to a folder named my_folder, where my_folder has already been created and exists
within /Common.
OPTIONS
definition
Holds the Tcl code.
description
User defined description.
events
Register events with the system that this script creates.
to-folder
An icall script can be moved to any folder under /Common, but configuration dependencies may restrict it from moving
out of /Common.
EVENT ACCESSORS
In addition to all the tmsh:: commands provided by the system to use in the Tcl scripts (please see help cli script), the
commands below are provided to access event specific information.
Hint: When you use a tmsh:: command, call it inside of Tcl catch to receive any error messages returned, and to allow the
script to exit gracefully if needed. Without Tcl catch, the script may crash and end the process.
The following Tcl variables may be used in triggered handlers. (The $ is not part of the variable name but is the lookup
operator for the Tcl variable.):
$EVENT::context([name])
An array variable containing the value of each context, keyed by the context name.
$EVENT::creation_time
The date and time the event was generated.
$EVENT::event_name
The name of the event that was generated.
$EVENT::handler_name
The name of the event handler that matched the event being handled.
$EVENT::script_name
The name of the currently running script.
For use in perpetual handlers:
EVENT::get_next [ -timeout [milliseconds] ]
The timeout parameter is optional. If the timeout is set, then EVENT::get_next will return 0 if no event matches before the
timeout hits. Otherwise, the EVENT::get_next will return 1, and the above variables in the EVENT:: namespace will be
replaced with the data from the new event.
SCRIPT EXAMPLES
The following script will print out all the information of an event.
puts "*** start of event ***"
foreach var [info vars EVENT::*] {
set varname [namespace tail $var]
if { [array exists $var] } {
puts "$varname: "
foreach { k v } [array get $var] { ;#k = key v = value
puts "$k:$v"
}
} else {
puts "$varname: [set $var]"
} }
The next script will allow events to hold bash commands and have the script execute them. The script would be required to
run inside an event handler that subscribed to the appropriate event and filtered on the words "utility" and "arguments".
set bash_cmd $EVENT::context(utility) append bash_cmd " " $EVENT::context(arguments)
if { [catch { exec /bin/bash -c $bash_cmd } result] } {
puts "error executing bash command: $bash_cmd" } else {
puts $result }
SEE ALSO
cli script, create, delete, edit, list, modify, show, sys icall event, sys icall event-handler, tmsh
COPYRIGHT
No part of this program may be reproduced or transmitted in any form or by any means, electronic or mechanical, including
photocopying, recording, or information storage and retrieval systems, for any purpose other than the purchaser's personal
use, without the express written permission of F5 Networks, Inc.
F5 Networks and BIG-IP (c) Copyright 2009-2013, 2016. All rights reserved.
BIG-IP 2016-03-14 sys icall script(1)