A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.cfengine.com/latest/reference-functions-execresult_as_data.html below:

execresult_as_data - CFEngine 3.26 Docs

Prototype: execresult_as_data(command, shell, output)

Return type: data

The return value is cached.

Description: Execute command and return a data container including command output and exit code.

Functions in the same way as execresult(), and takes the same parameters. Unlike execresult(), and returnszero(), this function allows you to test, store, or inspect both exit code and output from the same command execution.

Arguments:

Example:

Policy:

code

body common control
{
      bundlesequence  => { "example" };
}

bundle agent example
{
  vars:
      "my_data"
        data => execresult_as_data("echo 'hello'", "useshell", "both");
      "my_json_string"
        string => storejson(my_data);

  reports:
      "echo 'hello' returned '$(my_json_string)'";

}

Output:

code

R: echo 'hello' returned '{
  "exit_code": 0,
  "output": "hello"
}'

Notes: you should never use this function to execute commands that make changes to the system, or perform lengthy computations. Consider using commands promises instead, which have locking and are not evaluated by cf-promises.

See also: execresult().

History:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4