Applications
Start an interactive Python session
LR54 User Guide
764
Start an interactive Python session
Use the
python
command without specifying any parameters to start an interactive Python session.
The Python session operates interactively using REPL (Read Evaluate Print Loop) to allow you to write
Python code on the command line.
Note
The Python interactive session is not available from the Admin CLI. You must access the device
shell in order to run Python applications from the command line. See
for
information about configuring authentication groups that include shell access.
1. Select a device in Remote Manager that is configured to allow shell access to the admin user,
and click
Actions
>
Open Console
. Alternatively, log into the LR54 local command line as a
user with shell access.
Depending on your device configuration, you may be presented with an
Access selection
menu
. Type
shell
to access the device shell.
2. At the shell prompt, use the
python
command with no parameters to enter an interactive
Python session:
# python
Python 3.10.1 (default, May
9 2021, 22:49:59)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
3. Type Python commands at the Python prompt. For example, to view help for the digidevice
module, type:
>>> help("digidevice")
Help on package digidevice:
NAME
digidevice - Digi device python extensions
DESCRIPTION
This module includes various extensions that allow Python
to interact with additional features offered by the device.
...
4. Use
Ctrl-D
to exit the Python session. You can also exit the session using
exit()
or
quit()
.
Run a Python application at the shell prompt
Python applications can be run from a file at the shell prompt. The Python application will run until it
completes, displaying output and prompting for additional user input if needed. To interrupt the
application, enter
CTRL-C
.
Note
Python applications cannot be run from the Admin CLI. You must access the device shell in order
to run Python applications from the command line. See
for information about
configuring authentication groups that include shell access.