Execute using a child_process exec, for any async command
5660
function execSpawn(command, args, resultMsg, errorMsg) {
    return superspawn.spawn(command, args).then(function(result) {
        return resultMsg + result;
    }, function(error) {
        return errorMsg + error;
    });
}
1195896
async def execute_process(*cmd, log=None, loop=None):
    '''
    

    '''
    p = await asyncio.create_subprocess_exec(
        *cmd,
        stdin=asyncio.subprocess.PIPE,
        stdout=asyncio.subprocess.PIPE,
        stderr=asyncio.subprocess.PIPE,
        loop=loop)
    stdout, stderr = await p.communicate()
    if log:
        log.debug("Exec %s -> %d", cmd, p.returncode)
        if stdout:
            log.debug(stdout.decode('utf-8'))
        if stderr:
            log.debug(stderr.decode('utf-8'))
    return p.returncode == 0
1005493
def run(command, cwd=None, shell=False, raiseOnError=False):
		
		returncode = subprocess.call(command, cwd=cwd, shell=shell)
		if raiseOnError == True and returncode != 0:
			raise Exception('child process ' + str(command) + ' failed with exit code ' + str(returncode))
		return returncode
993413
function execProcess(command, options, onClose) {
    const procStart = process.hrtime(),
          cmd = command.join(' '),
          opts = options || {};

    childProcess.exec(cmd, opts, (error, stdout, stderr) => {
        const procEnd = process.hrtime(procStart),
              end = (procEnd[0] + procEnd[1] / 1e9).toFixed(2);

        logger.debug('Process output: %s', stdout);
        if (error) {
            logger.error('Process error: %s', stderr);
        }
        logger.debug('Execution time: %d sec', end);

        if (onClose) {
            onClose(error);
        }
    });
}
870703
function exec(cmd, args, options) {
    // If true user wants stdout to output value
    // instead of using inherit outputting
    // to process.stdout stream.
    if (options === true)
        options = { stdio: 'pipe' };
    options = chek_1.extend({}, spawnDefaults, options);
    if (chek_1.isString(args))
        args = argv_1.splitArgs(args);
    // Ensure command and arguments.
    if (!cmd)
        logger_1.log.error('Cannot execute process with command of undefined.');
    args = args.map(function (s) {
        if (/\s/g.test(s))
            return '"' + s + '"';
        return s;
    });
    // Spawn child.
    var child = child_process_1.spawnSync(cmd, args, options);
    if (child.stdout)
        return child.stdout.toString();
}
105448
def run(self, asynchronous=False):
        '''
        
        '''
        log.debug('Process Manager starting!')
        appendproctitle(self.name)

        # make sure to kill the subprocesses if the parent is killed
        if signal.getsignal(signal.SIGTERM) is signal.SIG_DFL:
            # There are no SIGTERM handlers installed, install ours
            signal.signal(signal.SIGTERM, self.kill_children)
        if signal.getsignal(signal.SIGINT) is signal.SIG_DFL:
            # There are no SIGINT handlers installed, install ours
            signal.signal(signal.SIGINT, self.kill_children)

        while True:
            log.trace('Process manager iteration')
            try:
                # in case someone died while we were waiting...
                self.check_children()
                # The event-based subprocesses management code was removed from here
                # because os.wait() conflicts with the subprocesses management logic
                # implemented in `multiprocessing` package. See #35480 for details.
                if asynchronous:
                    yield gen.sleep(10)
                else:
                    time.sleep(10)
                if not self._process_map:
                    break
            # OSError is raised if a signal handler is called (SIGTERM) during os.wait
            except OSError:
                break
            except IOError as exc:
                # IOError with errno of EINTR (4) may be raised
                # when using time.sleep() on Windows.
                if exc.errno != errno.EINTR:
                    raise
                break
871573
def execute_command(command):
    """"""

    command = shlex.split(command)
    try:
        process = subprocess.Popen(
            command,
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )
    except FileNotFoundError:
        raise RuntimeError("Command not found: {}".format(repr(command)))
    process.wait()
    # TODO: may use another codec to decode
    if process.returncode > 0:
        stderr = process.stderr.read().decode("utf-8")
        raise ValueError("Error executing command: {}".format(repr(stderr)))
    return process.stdout.read().decode("utf-8")
92765
def execute(command_line)
      result = collect_result(command_line, *spawn_process(command_line))
      result.wait
      result
    end
468654
def exec_cmd(self, command, **kwargs):
        

        if command == 'load':
            if kwargs:
                kwargs = dict(options=[kwargs])
        return self._exec_cmd(command, **kwargs)
250130
function execSync(command, ...args) {
    let result = child_process.spawnSync(command, args || [], { encoding: 'utf8' });

    // Docs say errors are thrown, but apparently not
    if (result.error) {
        throw new Error(JSON.stringify(result.error, null, 4));
    } else if (result.status !== 0) {
        throw new Error(result.stderr);
    }

    return result.stdout;
}
369618
function exec (cmd) {

        var deferred = Q.defer();

        faithfulExec(cmd)
            .then(function (result) {
                deferred.resolve(result);
            }, function (result) {
                deferred.reject(result);
            });

        return deferred.promise;

    }
1278308
async function _spawn(exe, args, options) {
    return new Promise((resolve, reject) => {
        try {
            const process = spawn(exe, args, options);
            process.on('error', error => {
                reject(error);
            });
            process.unref();
            if (process.pid !== undefined) {
                resolve(true);
            }
        } catch (error) {
            reject(error);
        }
    })
}
1134873
function run(commands, done) {
  var children = [];
  var pending = commands.length || 1;
  var err;
  each(commands, function(command, next) {
    children.push(childProcess.spawn(shell[0], [shell[1], command], {
      stdio: ['pipe', process.stdout, process.stderr]
    }).on('exit', function(code) {
      if (!err && code > 0) {
        err = new Error('`' + command + '` failed with exit code ' + code);
        children.forEach(function(child) {
          if (child.connected) child.kill();
        });
      }
      pending -= 1;
      if (pending === 0) done(err);
    }));
    next();
  });
}
503361
function execute(command, callback){
  exec(command, function(error, stdout, stderr){ callback(error, stdout); });
}
1198359
function ChildProcessFactory (
    nodeChildProcess,
    Errors,
    Logger,
    assert,
    util,
    Promise,
    Constants,
    _,
    fs,
    path
) {
    var logger = Logger.initialize(ChildProcessFactory);

    /**
     * ChildProcess provides a promise based mechanism to run shell commands
     * in a fairly secure manner.
     * @constructor
     */
    function ChildProcess (command, args, env, code, maxBuffer) {
        var self = this;

        assert.string(command);
        assert.optionalArrayOfNumber(code);

        self.command = command;
        self.file = self._parseCommandPath(self.command);
        self.args = args;
        self.environment = env || {};
        self.exitCode = code || [0];
        self.maxBuffer = maxBuffer || Constants.ChildProcess.MaxBuffer;

        if (!self.file) {
            throw new Error('Unable to locate command file (' + self.command +').');
        }
        if (!_.isEmpty(self.args)) {
            try {
                assert.arrayOfString(self.args, 'ChildProcess command arguments');
            } catch (e) {
                throw new Error('args must be an array of strings');
            }
        }

        self.hasBeenKilled = false;
        self.hasBeenCancelled = false;
        self.spawnInstance = undefined;
    }

    ChildProcess.prototype.createOwnDeferred = function() {
        var self = this;
        self._deferred = new Promise(function(resolve, reject) {
            self._resolve = resolve;
            self._reject = reject;
        });
    };

    ChildProcess.prototype.resolve = function(result) {
        if (!this._deferred.isPending()) {
            logger.error("ChildProcess promise has already been resolved");
            return;
        } else {
            this._resolve(result);
        }
    };

    ChildProcess.prototype.reject = function(error) {
        if (!this._deferred.isPending()) {
            logger.error("ChildProcess promise has already been rejected");
            return;
        } else {
            this._reject(error);
        }
    };

    ChildProcess.prototype.killSafe = function (signal) {
        if (!this.hasBeenKilled && this.spawnInstance && _.isFunction(this.spawnInstance.kill)) {
            this.spawnInstance.kill(signal);
        }
        this.hasBeenCancelled = true;
    };

    /**
     * Runs the given command.
     * @param  {String} command File to run, with path or without.
     * @param  {String[]} args    Arguments to the file.
     * @param  {Object} env     Optional environment variables to provide.
     * @param  {Integer} code   Desired exit code, defaults to 0.
     * @return {Promise}        A promise fulfilled with the stdout, stderr of
     * a successful command.
     */
    ChildProcess.prototype._run = function () {
        var self = this;

        if (self.hasBeenCancelled) {
            self.reject(new Errors.JobKilledError("ChildProcess job has been cancelled", {
                command: self.command,
                argv: self.args
            }));
            return;
        }

        self.hasBeenKilled = false;

        var options = {
            env: self.environment,
            maxBuffer: self.maxBuffer
        };

        self.spawnInstance = nodeChildProcess.execFile(
                self.file, self.args, options, function (error, stdout, stderr) {

            if (error && self.exitCode.indexOf(error.code) === -1) {
                self.hasBeenKilled = true;
                logger.error('Error Running ChildProcess.', {
                    file: self.file,
                    argv: self.args,
                    stdout: stdout,
                    stderr: stderr,
                    error: error
                });
                self.reject(error);
            } else {
                self.hasBeenKilled = true;
                self.resolve({
                    stdout: stdout,
                    stderr: stderr
                });
            }
        })
        .on('close', function(code, signal) {
            if (signal) {
                logger.warning("Child process received closing signal:", {
                    signal: signal,
                    argv: self.args
                });
            }
            self.hasBeenKilled = true;
        })
        .on('error', function(code, signal) {
            logger.error("Child process received closing signal but has " +
                "already been closed!!!", {
                signal: signal,
                argv: self.args
            });
        });
    };

    ChildProcess.prototype._runWithRetries = function(retryCount, delay, retries) {
        var self = this;

        // Max out exponential backoff to 60 seconds.
        delay = delay > 60000 ? 60000 : delay;

        if (!self._deferred) {
            self.createOwnDeferred();
        }

        self._run();

        return self._deferred.catch(function(e) {
            if (e instanceof Errors.JobKilledError) {
                throw e;
            } else if (retryCount < retries) {
                logger.debug("Retrying ChildProcess command.", {
                    file: self.file,
                    args: self.args
                });
                // Create new deferred promise in here instead of above, in case we receive an
                // external cancellation during the below delay, so we don't
                // try to reject using the previous deferred object.
                self.createOwnDeferred();
                return Promise.delay(delay)
                .then(function() {
                    return self._runWithRetries(retryCount + 1, delay * 2, retries);
                });
            } else {
                throw e;
            }
        });
    };

    ChildProcess.prototype.run = function(options) {
        options = options || {};
        options.retries = options.retries || 0;
        if (options.delay !== 0) {
            options.delay = options.delay || 500;
        }

        return this._runWithRetries(0, options.delay, options.retries);
    };

    /**
     * Internal method to identify the path to the command file.  It's essentially
     * unix which in JavaScript.
     * @private
     */
    ChildProcess.prototype._parseCommandPath = function _parseCommandPath (command) {
        var self = this;

        if (self._fileExists(command)) {
            return command;
        } else {
            var found = _.some(self._getPaths(), function (current) {
                var target = path.resolve(current + '/' + command);

                if (self._fileExists(target)) {
                    command = target;

                    return true;
                }
            });

            return found ? command : null;
        }
    };

    /**
     * Internal method to verify a file exists and is not a directory.
     * @private
     */
    ChildProcess.prototype._fileExists = function _fileExists (file) {
        return fs.existsSync(file) && !fs.statSync(file).isDirectory();
    };

    /**
     * Internal method to get an array of directories in the users path.
     * @private
     */
    ChildProcess.prototype._getPaths = function _getPaths () {
        var path = process.env.path || process.env.Path || process.env.PATH;
        return path.split(':');
    };

    return ChildProcess;
}
1344541
def execute_command(self, cmnd, *args, **options):
        ""
        args, options = self.preprocess_command(cmnd, *args, **options)
        return self.client.execute_command(cmnd, *args, **options)
608968
function exec(command, options) {
    return ((args) => spawn(args.shift(), args, options))(command.split(' '));
}