The Eggplant Network Emulator can be scripted in one of two ways:
- Use the supplied sample Python command-line script, epncli.py. You can download this script from the Eggplant downloads page for Eggplant Network.
Note: This method requires an installed Python interpreter.
- Use an application that creates a TCP socket and connects directly to the Emulator over TCP port 7292 using SSL.
When using the command-line script or API, there are certain requirements that must be met in order to get a successful outcome. Whether used from the API or from the command-line interface (CLI), all of the command options are prefixed with '--' (two dashes) to help them stand out. Where there is an argument, the argument should be quoted to avoid problems with spaces. Also, a valid username and password must be supplied for the Emulator.
For example, from Windows (assuming the epncli.py script is available in the local folder and a Python interpreter is installed in the PATH environment variable), you could issue the following command:
C:\Users\Lara>python epncli.py --host 192.168.202.194 --user admin -password admin --getemulationsbyportpair
Some commands require more than one parameter. When that is the case, you still use only one argument and the parameters follow it, separated by a semicolon.
The epncli.py script sends all of the commands (except for --host) directly to the Emulator and echo’s any responses direct to the terminal (stdout). Responses from the Emulator are also in the form of commands and values. For commands that do not have a specific response, the command --ok is returned. If there is an error when executing the command, it returns --error "<Message>".
Below are some examples along with their return values:
C:\Users\Lara>python epncli.py --host 192.168.202.194 --user admin -password admin --getlicense ports
C:\Users\Lara>python epncli.py --host 192.168.202.194 --user admin -password admin --notACommand
--error "Option [--notACommand] Unknown"
For full information on how to use the command line and also the sockets API, see Issuing Eggplant Network Emulator Commands.