11: Scripts
EMG™ Edge Management Gateway User Guide
218
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)
5. 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).
6. The script cannot contain commands which spawn or fork other commands, read or write files
on the EMG filesystem, or interrogate the EMG filesystem. The list of commands that are not
Содержание EMG 8500
Страница 1: ...Part Number PMD 00008 Revision A October 2019 EMG Edge Management Gateway User Guide EMG 8500 ...
Страница 69: ...6 Networking EMG Edge Management Gateway User Guide 69 Figure 6 2 Network Network Settings 2 of 2 ...
Страница 302: ...14 Maintenance EMG Edge Management Gateway User Guide 302 Figure 14 12 About EMG ...