# 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.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FIGDRVM3RyZO6QAAVWHYe%2Fimage.png?alt=media&#x26;token=7ac687db-5dcd-429d-b6e0-1796b47b815f" alt=""><figcaption></figcaption></figure></div>

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**:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2Fj8Mve5014Zg5IOVcyb4f%2Fimage.png?alt=media&#x26;token=9a9d4457-0b6d-4a38-89d3-1dae799e6599" alt=""><figcaption></figcaption></figure></div>

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
```

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FDS8CH6SzBWArWESCXrk0%2Fimage.png?alt=media&#x26;token=2eb655ee-1c40-4d58-81fa-c293669be180" alt=""><figcaption></figcaption></figure></div>

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:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FVTLFCk119lryx2fZj3ZZ%2Fimage.png?alt=media&#x26;token=7f793371-998e-4660-b434-ba828a73af23" alt=""><figcaption></figcaption></figure></div>

## Further Reading <a href="#f02da759-c9c3-402a-9b7b-9656db8eb02e" id="f02da759-c9c3-402a-9b7b-9656db8eb02e"></a>

<https://content.cisco.com/chapter.sjs?uri=/searchable/chapter/content/en/us/td/docs/iosxr/ncs5500/programmability/78x/b-programmability-cg-ncs5500-78x/process-scripts.html.xml>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ccie-sp.gitbook.io/ccie-spv5.1-labs/labs/app-hosting/notes-process-scripts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
