Notes - Process Scripts
Process scripts do not appear to be on the SPv5.1 blueprint, however they are worth exploring because they are an easy way to run custom python scripts on the router.
First we create the python script off-box.
clab@Ubuntu:~$ cat hello-world.py
import time
from cisco.script_mgmt import xrlog
syslog = xrlog.getSysLogger('Sample')
while True:
syslog.info('Hello World!')
time.sleep(30)
This is transferred to the router.
scp hello-world.py cisco@10.100.100.101:/harddisk:/
The script is added to the script management repository. The space between the directory and script name is necessary.
RP/0/RP0/CPU0:XR1#script add process /harddisk:/ hello-world.py
Wed Jan 24 12:44:43.799 UTC
Copying script from /harddisk:/hello-world.py
hello-world.py has been added to the script repository
RP/0/RP0/CPU0:XR1#
At this point, the script cannot be used until the checksum is manually configured on the router.

We can generate the checksum from our Ubuntu box.
clab@Ubuntu:~$ sha256sum hello-world.py
b4dbd303ca36cb1ef4bab9fe588aa4fae1da83eb849a8517969defcb61170a51 hello-world.py
This is pasted into the router’s config.
script process hello-world.py checksum SHA256 b4dbd303ca36cb1ef4bab9fe588aa4fae1da83eb849a8517969defcb61170a51
commit
The status is now Ready:

We now manage the app from appmgr:
appmgr
process-script hello-world
executable hello-world.py
The process script must be activated now using appmgr:
appmgr process-script activate name hello-world

I’ve found that the print output from a python script does not seem to generate any logs in show appmgr process-script hello-world logs. However, the syslog.info() function does generate log messages on the router directly:

Further Reading
Last updated