12: Scripts
EMG™ Edge Management Gateway User Guide
259
Custom Script Syntax
This section describes the scripting syntax for Custom Scripts. The syntax is more flexible than
Interactive Script syntax, but still has restrictions to prevent the creation of scripts containing
potentially harmful commands. In addition, Custom Scripts can be configured to use command line
parameters. Custom Scripts have the following guidelines:
1. The size of the script file cannot exceed 6 Kbytes.
2. The size of the results generated by the script cannot exceed 1 Kbyte (any results over 1Kbyte
will be truncated).
3. The first line of the script must contain a Linux script style interpreter directive so that the EMG
will know which interpreter to use to run the script. Currently only Expect is supported. The
format of the first line is
#! expect, #! tcl,
or
#! python
. When a custom script is
imported, the interpreter line must match the selected script or file type (Expect, Tcl, or
Python), otherwise the script will be invalid.
4. The script should include a spawn command to connect the script to either an EMG CLI
session or an EMG Device Port session. Refer to the following spawn command syntax:
Note:
For CLI sessions, a local user name should be given
For Device Port sessions, the $devicePort variable will be used by the EMG to
connect the script to the appropriate Device Port. The
-noecho
flag may be passed
to
spawn
command.
Expect script - CLI session
spawn clisession -U <username>
Expect script - Device Port session
spawn portsession -p $devicePort
Tcl script - CLI session
set io [open "| clisession -U <username>" r+]
Tcl script - Device Port session
set io [open "| portsession -p $devicePort" r+]
Python script - CLI session
subprocess.Popen(['clisession', '-U', '<username>'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
Python script - Device Port session
subprocess.Popen(['portsession', '-p', devicePort],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
It is recommended that scripts that spawn clisession only be used with the
set script
runcli
command (and not the
connect script
command), and that scripts that spawn
portsession only be used with the
connect script
command (and not the
set script
runcli
command). Scripts that spawn a session should properly wait for the session to end
before exiting the script; for example in an Expect script that spawns clisession, the script
should include a
wait -i $sessionId
after sending the "logout" command to the
Summary of Contents for EMG 7500
Page 100: ...7 Networking EMG Edge Management Gateway User Guide 100 Figure 7 5 Network Wireless Settings ...
Page 353: ...15 Maintenance EMG Edge Management Gateway User Guide 353 Figure 15 12 About EMG ...
Page 474: ...EMG Edge Management Gateway User Guide 474 Figure E 3 EU Declaration of Conformity ...
Page 475: ...EMG Edge Management Gateway User Guide 475 Figure E 4 EU Declaration of Conformity continued ...