runs the given cmd as shell command
977869
def sh(args, **kwargs):
    
    if isinstance(args, str):
        args = args.split()
    if not args:
        return
    click.echo('$ {0}'.format(' '.join(args)))
    try:
        return subprocess.check_call(args, **kwargs)
    except subprocess.CalledProcessError as exc:
        click.secho('run error {}'.format(exc))
    except OSError as exc:
        click.secho('not found error {}'.format(exc))
363354
def run_process(cmd, stdin=None, iterate_stdin=True, output_chunk_size=1024, shell=True, to_close=None, cwd=None):
    
    try:
        p = subprocess.Popen(cmd, shell=shell, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd)

        if stdin:
            if iterate_stdin:
                stdin_iter = iter(stdin)
                stdin_buffer = ''
                stdin_available = True
            else:
                stdin_buffer = stdin
                stdin_available = False

        write_set = []
        read_set = []
        output_buffer = ''

        if p.stdin and stdin:
            write_set.append(p.stdin)
        if p.stdout:
            read_set.append(p.stdout)
        if p.stderr:
            read_set.append(p.stderr)

        while read_set or write_set:
            try:
                rlist, wlist, xlist = select.select(read_set, write_set, [])
            except select.error as e:
                if e.args[0] == errno.EINTR:
                    continue
                raise

            if p.stdin in wlist:
                while len(stdin_buffer) < _PIPE_BUF and stdin_available:
                    try:
                        stdin_buffer += stdin_iter.next()
                    except StopIteration:
                        stdin_available = False
                chunk = stdin_buffer[:_PIPE_BUF]
                bytes_written = os.write(p.stdin.fileno(), chunk)
                stdin_buffer = stdin_buffer[bytes_written:]

                if not (stdin_buffer or stdin_available):
                    p.stdin.close()
                    write_set.remove(p.stdin)

            if p.stdout in rlist:
                data = os.read(p.stdout.fileno(), output_chunk_size)
                if data == '':
                    p.stdout.close()
                    read_set.remove(p.stdout)
                if data:
                    output_buffer += data
                    yield data

            if p.stderr in rlist:
                data = os.read(p.stderr.fileno(), output_chunk_size)
                if data == '':
                    p.stderr.close()
                    read_set.remove(p.stderr)
                if data:
                    output_buffer += data

            if len(output_buffer) > output_chunk_size:
                output_buffer = output_buffer[-output_chunk_size:]

        return_code = p.poll()
        if return_code:
            e = subprocess.CalledProcessError(return_code, cmd)
            e.output = output_buffer
            raise e
    finally:
        if to_close:
            to_close.close()
492530
def run_cmd(self, *args, **kwargs):
        
        timeout = kwargs.pop('timeout', None)
        p = self.raw_cmd(*args, **kwargs)
        return p.communicate(timeout=timeout)[0].decode('utf-8').replace('\r\n', '\n')
351826
def _run(cmd):
    '''
    
    '''
    return __salt__['cmd.run_all'](cmd, env={'HOME': os.path.expanduser('~{0}'.format(__opts__['user']))})
570293
def run_cmd(call, cmd, *, echo=True, **kwargs):
    """"""
    if echo:
        print('$> ' + ' '.join(map(pipes.quote, cmd)))
    return call(cmd, **kwargs)
1193043
def run(cmd, data=None, checks=None, region=None, log_error=True,
        log_stdout=False):
    
    try:
        logger.debug(" ".join(str(x) for x in cmd) if not isinstance(cmd, basestring) else cmd)
        _do_run(cmd, checks, log_stdout)
    except:
        if log_error:
            logger.info("error at command")
        raise
1049427
def run(command):
    
    p = Popen(command.split(), stdout=PIPE, stderr=PIPE)
    (stdout, stderr) = p.communicate()
    return (p.returncode, [line.strip() for line in stdout.splitlines()],
            [line.strip() for line in stderr.splitlines()])
788225
def run_cmd(cmd, out=os.path.devnull, err=os.path.devnull):
    

    logger.debug(' '.join(cmd))
    with open(out, 'w') as hout:
        proc = subprocess.Popen(cmd, stdout=hout, stderr=subprocess.PIPE)
        err_msg = proc.communicate()[1].decode()
    with open(err, 'w') as herr:
        herr.write(str(err_msg))
    msg = '({}) {}'.format(' '.join(cmd), err_msg)
    if proc.returncode != 0:
        logger.error(msg)
        raise RuntimeError(msg)
566842
def run_command(*args)
      require 'tempfile'
      out = Tempfile.new('tty-screen')
      result = system(*args, out: out.path, err: File::NULL)
      return if result.nil?
      out.rewind
      out.read
    ensure
      out.close if out
    end
669450
def _run(cmd, suppress_errors=False, suppress_output=False):
    
    if is_verbose():
        logger.debug('Executing: "%s"', format(cmd))
    process = subprocess.Popen(
        cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

    stderr_log_level = logging.NOTSET if suppress_errors else logging.ERROR
    stdout_log_level = logging.NOTSET if suppress_output else logging.DEBUG

    stdout_thread = PipeReader(
        process.stdout, process, logger, stdout_log_level)
    stderr_thread = PipeReader(
        process.stderr, process, logger, stderr_log_level)

    stdout_thread.start()
    stderr_thread.start()

    while process.poll() is None:
        time.sleep(PROCESS_POLLING_INTERVAL)

    stdout_thread.join()
    stderr_thread.join()

    process.aggr_stdout = stdout_thread.aggr
    process.aggr_stderr = stderr_thread.aggr

    return process
934054
def run (cmd, verbosity=0, **kwargs):
    """"""
    # Note that shell_quote_nt() result is not suitable for copy-paste
    # (especially on Unix systems), but it looks nicer than shell_quote().
    if verbosity >= 0:
        log_info("running %s" % " ".join(map(shell_quote_nt, cmd)))
    if kwargs:
        if verbosity >= 0:
            log_info("    with %s" % ", ".join("%s=%s" % (k, shell_quote(str(v)))\
                                           for k, v in kwargs.items()))
        if kwargs.get("shell"):
            # for shell calls the command must be a string
            cmd = " ".join(cmd)
    if verbosity < 1:
        # hide command output on stdout
        with open(os.devnull, 'wb') as devnull:
            kwargs['stdout'] = devnull
            res = subprocess.call(cmd, **kwargs)
    else:
        res = subprocess.call(cmd, **kwargs)
    return res
1252463
def run(self, command):
        
        if isinstance(command, basestring):
            command = command.split()
        else:
            command = list(command)
        self.external.omero_cli(command)
563005
def _runcmd(progargs, stdinput=None):
    '''
    
    '''
    stdin = None
    if stdinput is not None:
        assert(isinstance(stdinput, list))
        stdin=PIPE

    err = 0
    output = b''
    log_debug("Calling {} with input {}".format(' '.join(progargs), stdinput))
    try:
        p = Popen(progargs, shell=True, stdin=stdin, 
            stderr=STDOUT, stdout=PIPE, universal_newlines=True)
        if stdinput is not None:
            for cmd in stdinput:
                print(cmd, file=p.stdin)
            p.stdin.close()
        output = p.stdout.read()
        p.stdout.close()
        err = p.wait(timeout=1.0)
    except OSError as e:
        err = e.errno
        log_warn("Error calling {}: {}".format(progargs, e.stderror))
    except Exception as e:
        errstr = str(e)
        log_warn("Error calling {}: {}".format(progargs, errstr))
        err = -1
    log_debug("Result of command (errcode {}): {}".format(err, output))
    return err,output
1340605
def run(cmd, *, args='', timeout=600):
    

    # type checks
    utils.chkstr(cmd, 'cmd')
    utils.chkstr(args, 'args')

    # execute the command
    r = envoy.run("{cmd} {args}".format(cmd=cmd, args=args), timeout=timeout)
    # log stdout
    log.msg_debug("{cmd} > {stdout}".format(cmd=cmd, stdout=r.std_out.strip()))

    # In this way, we will know what went wrong on execution
    if r.status_code:
        log.msg_err("{cmd} > {stderr}".format(cmd=cmd,
                                              stderr=r.std_err.strip()))
        raise OSError("[{cmd}] execution failed!".format(cmd=cmd))
701488
def _run(self, cmd):
        '''
        
        '''

        if isinstance(cmd, six.string_types):
            cmd = salt.utils.args.shlex_split(cmd)

        try:
            log.debug(cmd)
            p = subprocess.Popen(
                cmd,
                shell=True,
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE)
            return p.communicate()

        except (OSError, IOError) as exc:
            log.debug('Command Failed: %s', ' '.join(cmd))
            log.debug('Error: %s', exc)
            raise CommandExecutionError(exc)
466706
function runCommand(cmd, args, options) {
  return new Promise((resolve, reject) => {
    const spwan = spawn(
      cmd,
      args,
      Object.assign(
        {
          cwd: process.cwd(),
          stdio: 'inherit',
          shell: true,
        },
        options
      )
    )

    spwan.on('exit', () => {
      resolve()
    })
  })
}
1012599
def run(cls, command, cwd=".", **kwargs):
        
        assert isinstance(command, six.string_types)
        command_result = CommandResult()
        command_result.command = command
        use_shell = cls.USE_SHELL
        if "shell" in kwargs:
            use_shell = kwargs.pop("shell")

        # -- BUILD COMMAND ARGS:
        if six.PY2 and isinstance(command, six.text_type):
            # -- PREPARE-FOR: shlex.split()
            # In PY2, shlex.split() requires bytes string (non-unicode).
            # In PY3, shlex.split() accepts unicode string.
            command = codecs.encode(command, "utf-8")
        cmdargs = shlex.split(command)

        # -- TRANSFORM COMMAND (optional)
        command0 = cmdargs[0]
        real_command = cls.COMMAND_MAP.get(command0, None)
        if real_command:
            cmdargs0 = real_command.split()
            cmdargs = cmdargs0 + cmdargs[1:]
        preprocessors = cls.PREPROCESSOR_MAP.get(command0)
        if preprocessors:
            cmdargs = cls.preprocess_command(preprocessors, cmdargs, command, cwd)


        # -- RUN COMMAND:
        try:
            process = subprocess.Popen(cmdargs,
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE,
                            universal_newlines=True,
                            shell=use_shell,
                            cwd=cwd, **kwargs)
            out, err = process.communicate()
            if six.PY2: # py3: we get unicode strings, py2 not
                default_encoding = 'UTF-8'
                out = six.text_type(out, process.stdout.encoding or default_encoding)
                err = six.text_type(err, process.stderr.encoding or default_encoding)
            process.poll()
            assert process.returncode is not None
            command_result.stdout = out
            command_result.stderr = err
            command_result.returncode = process.returncode
            if cls.DEBUG:
                print("shell.cwd={0}".format(kwargs.get("cwd", None)))
                print("shell.command: {0}".format(" ".join(cmdargs)))
                print("shell.command.output:\n{0};".format(command_result.output))
        except OSError as e:
            command_result.stderr = u"OSError: %s" % e
            command_result.returncode = e.errno
            assert e.errno != 0

        postprocessors = cls.POSTPROCESSOR_MAP.get(command0)
        if postprocessors:
            command_result = cls.postprocess_command(postprocessors, command_result)
        return command_result