Module:digicli
From Digi Developer
Warning! Using this module limits your ability to port your Python code to other product families. To maintain portability, use the RCI module instead.
The digicli module exports a single function, also named digicli. This function takes a single string as an argument. That string is a command to be executed by the command line interpreter of the Digi box. The status and result of the command will be returned in a tuple. The first element is a boolean that indicates whether the command succeeded. The second element of the tuple is a list of the return text from the command separated into lines. For all Command Line commands, refer to the "Command Reference: Digi Connect Family" located on this page: http://www.digi.com/support/productdetl.jsp?pid=3442&osvid=0&tp=3&tp2=0
Contents |
Example
This example will demonstrate extracting the MAC address from a device with one Ethernet or 802.11 interface.
import digicli status, output = digicli.digicli('show net') if status: for line in output: if line.find('MAC Address') >= 0: l = line.split(':') print "".join(l[1:]).strip()
Notes
The more complex show network output of devices with more than one Ethernet or 802.11 interfaces requires a different parsing method.
Availability
Products which support this module
- Most of the Digi Connect/ConnectPort products support this module, such as WAN, X2, X4 and X5.
- The ConnectPort LTS supports this module
Products which DO NOT support this module
- The Digi ConnectPort X3 (all variations) does not support this.
- Transport does not support this module
- Passport and Cm products do not support Python
- Future gateways will NOT support this module.
