Execute a command and read the output as YAMLEX
19294
def ext_pillar(minion_id,  # pylint: disable=W0613
               pillar,  # pylint: disable=W0613
               command):
    '''
    
    '''
    try:
        command = command.replace('%s', minion_id)
        return deserialize(__salt__['cmd.run']('{0}'.format(command)))
    except Exception:
        log.critical('YAML data from %s failed to parse', command)
        return {}
523421
def _run(command, quiet=False, timeout=None):
    """"""
    try:
        with _spawn(command, quiet, timeout) as child:
            command_output = child.read().strip().replace("\r\n", "\n")
    except pexpect.TIMEOUT:
        logger.info(f"command {command} timed out")
        raise Error()

    return command_output
400284
function(state, command, output)
  {
    console.log('> Finished execution of ``', command, '``' + withCmdPrefix(state) + ':');
    if (!Array.isArray(output)) output = [output];
    console.log('```');
    console.log(output.map(format).join('\n'));
    console.log('```');
  }
524900
def execute_command(cls, command):
        
        return Popen(
            command,
            stdout=PIPE,
            stderr=STDOUT,
            start_new_session=True
        )
960980
def save_yaml(self, outFile):
        """"""
        with open(outFile,'w') as myfile:
            print(yaml.dump(self.params), file=myfile)
1033471
def cli(yamlfile, format, output, collections):
    
    print(ShExGenerator(yamlfile, format).serialize(output=output, collections=collections))
1142590
def _run_cmd_get_output(cmd):
    
    process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
    out, err = process.communicate()
    return out or err
93994
def getOutput(self, command, env={}, path=None,
                  uid=None, gid=None, usePTY=0, childFDs=None):
        
        deferred = defer.Deferred()
        processProtocol = _SummaryProcessProtocol(deferred)
        self.execute(processProtocol, command, env,
                     path, uid, gid, usePTY, childFDs)
        @deferred.addCallback
        def getStdOut(tuple_):
            stdout, _stderr, _returnCode = tuple_
            return stdout
        return deferred
1182483
def exec_result(obj, local, stream):
    """"""
    local['_'] = obj
    if obj is not None:
        print(repr(obj), file=stream)
917414
function exec(command) {
  var tempName = temp.path({suffix: '.exec'});
  var cmd;
  if (isWindows)
    cmd = command + ' > ' + tempName + ' 2>&1';
  else
    cmd = '(' + command + ') > ' + tempName + ' 2>&1';

  var code = run(cmd);
  var text;

  if (fs.existsSync(tempName)) {
    try {
      text = fs.readFileSync(tempName, 'utf8');
      fs.unlink(tempName);
    } catch (err) {
      throw new Error('ERROR: could not delete capture file');
    }
  } else {
    throw new Error('ERROR: output not captured');
  }

  return {
    code: code,
    stdout: text
  }
}
352675
def _read_output(self, command):
        
        cmd = []
        cmd.extend(self._prefix)
        cmd.extend([self._path, "-iP"])
        cmd.extend(command)
        command = cmd

        logger.debug("Cmd %s" % command)
        null = open('/dev/null', 'w')
        process = subprocess.Popen(
            command, stdout=subprocess.PIPE, stderr=null)
        null.close()

        results = []
        reader = csv.reader(_input_csv(process.stdout), delimiter=str("|"))

        try:
            headers = next(reader)
            logger.debug("<-- headers %s" % headers)
        except StopIteration:
            logger.debug("Cmd %s headers not found" % command)
            headers = []

        for row in reader:
            _output_csv(row)

            logger.debug("<-- row %s" % row)
            this_row = {}

            i = 0
            for i in range(0, len(headers)):
                key = headers[i]
                value = row[i]
                this_row[key] = value

            results.append(this_row)

        process.stdout.close()
        retcode = process.wait()
        if retcode != 0:
            logger.error("<-- Cmd %s returned %d (error)" % (command, retcode))
            raise subprocess.CalledProcessError(retcode, command)

        if len(headers) == 0:
            logger.error("Cmd %s didn't return any headers." % command)
            raise RuntimeError("Cmd %s didn't return any headers." % command)

        logger.debug("<-- Returned: %d (good)" % retcode)
        return results
1220973
def exec_output(cls, command, shell=True, encoding='utf-8'):
        
        proc = Popen(command, shell=shell, stdout=PIPE)
        stdout, _stderr = proc.communicate()
        if proc.returncode == 0:
            return stdout.decode(encoding)

        return ''
1267004
def execute(cmd):
    

    # Parse cmd string to a list
    if not isinstance(cmd, list):
        cmd = shlex.split(cmd)
    # Execute command
    rc = 0
    output = ""
    try:
        output = subprocess.check_output(cmd, close_fds=True,
                                         stderr=subprocess.STDOUT)
    except subprocess.CalledProcessError as err:
        rc = err.returncode
        output = err.output
    except Exception as err:
        err_msg = ('Command "%s" Error: %s' % (' '.join(cmd), str(err)))
        raise exception.SDKInternalError(msg=err_msg)

    output = bytes.decode(output)
    return (rc, output)
735093
async function executeCommand(command){
    // execute command
    await write(command + '\n');

    // fetch echo
    const data = await getNextResponse();

    return {
        echo: data.echo,
        response: data.response
    };
}
623528
def print_yaml(o):
    """"""
    print(yaml.dump(o, default_flow_style=False, indent=4, encoding='utf-8'))
171513
def execute_command(cmd, execute, echo=True):
    """"""
    if execute:
        if echo:
            print("Executing: " + cmd)
        return os.system(cmd)
    else:
        print(cmd)
        return 0
131496
def _execute(cmd):
        """"""
        cmd_parts = shlex.split(cmd)
        if sys.version_info[0] < 3:

            cmd_parts = shlex.split(cmd.encode('ascii'))

        proc = subprocess.Popen(
            cmd_parts,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )
        out, err = proc.communicate()
        if proc.returncode != 0:

            raise subprocess.CalledProcessError(
                returncode=proc.returncode,
                cmd=cmd,
                output=err,
            )

        return CommandResult(
            code=proc.returncode,
            out=out.decode('utf8'),
            err=err.decode('utf8'),
        )