# 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: 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://nso-docs.cisco.com/guides/nso-6.6/resources/man/ncs_cmd.1.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.
