Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-3315

Function that allows inspection of output and return code - execresult_as_data()

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Done
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.17.0
    • Component/s: None
    • Labels:
      None
    • Story Points:
      8

      Description

      It would be nice if there were a function that would allow me to inspect the return code and output from a command execution, combining some of the usefulness of returnszero() and execresult().

      Perhaps data_execresult() where instead of returning a string or a class, it would return a data container that included the return code and output.

      Example data container returned
      {
        "returncode": "0",
        "output": "I've got a lovely bunch of coconuts."
      } 
      

      As indicated in CFE-3108, it would be nice to have the ability to differentiate ate between stderr and stdout.

      Example more detailed data container returned when desire capture of stderr
      {
        "returncode": "0",
        "output": "ERROR: palm trees don't grow here."
      } 
      
      Example more detailed data container returned when desire capture of interleaved/both stderr and stdout
      {
        "returncode": "0",
        "output": "I've got a lovely bunch of coconuts.
      ERROR: palm trees don't grow here."
      } 
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                olehermanse Ole Herman Schumacher Elgesem
                Reporter:
                a10042 Nick Anderson
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel