> For the complete documentation index, see [llms.txt](https://nso-docs.cisco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nso-docs.cisco.com/guides/nso-6.5/resources/man/ncs_cmd.1.md).

# ncs\_cmd

`ncs_cmd` - Command line utility that interfaces to common NSO library functions

## Synopsis

`ncs [common options] [filename]`

`ncs [common options] -c string`

`ncs -h | -h commands | -h command-name`

Common options:

`[-r | -o | -e | -S] [-f [w] | [p] | [r | s]] [-a address] [-p port] [-u user] [-g group] [-x context] [-s] [-m] [-h] [-d]`

## Description

The `ncs_cmd` utility is implemented as a wrapper around many common CDB and MAAPI function calls. The purpose is to make it easier to prototype and test various NSO issues using normal scripting tools.

Input is provided as a file (default `stdin` unless a filename is given) or as directly on the command line using the `-c string` option. The `ncs_cmd` expects commands separated by semicolon (;) or newlines. A pound (#) sign means that the rest of the line is treated as a comment. For example:

```
ncs_cmd -c get_phase
```

Would print the current start-phase of NSO, and:

```
ncs_cmd -c "get_phase ; get_txid"
```

would first print the current start-phase, then the current transaction ID of CDB.

Sessions towards CDB, and transactions towards MAAPI are created as-needed. At the end of the script any open CDB sessions are closed, and any MAAPI read/write transactions are committed.

## Options

`-d`

> Debug flag. Add more to increase debug level. All debug output will be to stderr.

`-m`

> Don't load the schemas at startup.

## Environment Variables

`NCS_IPC_ADDR`

> The address used to connect to the NSO daemon, overrides the compiled in default.

`NCS_IPC_PORT`

> The port number to connect to the NSO daemon on, overrides the compiled in default.

## Examples

1. Getting the address of eth0

   ```
   ncs_cmd -c "get /sys:sys/ifc{eth0}/ip"
   ```
2. Setting a leaf in CDB operational

   ```
   ncs_cmd -o -c "set /sys:sys/ifc{eth0}/stat/tx 88"
   ```
3. Making NSO running on localhost the HA primary, with the name node0

   ```
   ncs_cmd -c "primary node0"
   ```

   Then tell the NSO also running on localhost, but listening on port 4566, to become secondary and name it node1

   ```
   ncs_cmd -p 4566 -c "secondary node1 node0 127.0.0.1"
   ```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://nso-docs.cisco.com/guides/nso-6.5/resources/man/ncs_cmd.1.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
