extcmd

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

The extcmd package provides a simple interface which allows an external command to be invoked with the resulting stdout/err placed into a json formatted structure for the caller. The current limitation is 8192 output lines; if more are generated by the executed command they are truncated.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cmd2json

func Cmd2json(cbuf string, rtype string) (jdata []byte, err error)

Executes a command and returns the response structure in json format

func Cmd2strings

func Cmd2strings(cbuf string) (rdata []string, edata []string, err error)

Accept and build a command, run it writing the output into a json buffer that is returned. Currently, output response is truncated at 8192 records. If a caller needs more, then it should redirect the output and parse the file rather than reading it all into core.

Types

type Response

type Response struct {
	Ctype  string
	Rtype  string
	Rstate int
	Rdata  []string
	Edata  []string
}

func Cmd2resp

func Cmd2resp(cbuf string, rtype string) (rblock *Response, err error)

Execute the command in cbuf and return a Response structure with the results.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL