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.
This is pasted into the router’s config.
The status is now Ready:

We now manage the app from appmgr:
The process script must be activated now using appmgr:

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