sys icall scriptΒΆ

sys icall script(1)					BIG-IP TMSH Manual				       sys icall script(1)

       script - Manage a Tcl script used by handlers during execution on the BIG-IP(r) system.

       sys icall

       Manage the script component within the sys icall module using the syntax shown in the following sections.

	create script [name]
	modify script [name]
	edit script [name]
	  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] ]	    |
		    [ [] to-folder [folder-name] ] ]

	list script
	list script [name]

	delete script [name]

       Note: You must remove all references to the icall script before deletion.

       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.

       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.

	    Holds the Tcl code.

	    User defined description.

	    Register events with the system that this script creates.

	    An icall script can be moved to any folder under /Common, but configuration dependencies may restrict it from moving
	    out of /Common.

       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.):


       An array variable containing the value of each context, keyed by the context name.


       The date and time the event was generated.


       The name of the event that was generated.


       The name of the event handler that matched the event being handled.


       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.

       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 }

       cli script, create, delete, edit, list, modify, show, sys icall event, sys icall event-handler, tmsh

       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)