Runs the given command in a child process.

Returns a promise that is resolved with the generated
stdout of the command (as UTF-8 string) when the child process
terminates normally or rejected if the child process
terminates with a non-zero exit code.
345405
function runCommand(command) {
    return new Promise((resolve, reject) => {
        utils.logInfo(`Command: ${command}`);
        childProcess.exec(command, (error, stdout, stderr) => {
            // If exec returns content in stderr, but no error, print it as a warning.
            // If exec returns an error, reject the promise.
            if (error) {
                reject(error);
                return;
            } else if (stderr) {
                utils.logInfo(stderr);
            }
            resolve(stdout);
        });
    });
}
76744
function promiseCommand(command) {
    const opts = {
        env: process.env
    };
    console.log('>>>>', command)
    return spawnShell(command, opts).exitPromise
        .then((exitCode) => {
            if (exitCode === 0) {
                return;
            } else {
                throw Error("Exit " + exitCode)
            }
        })
}
730873
def _execute(self, command, stdin=None, stdout=subprocess.PIPE):
        
        process = subprocess.Popen(command, shell=True, cwd=self.root_path, stdin=stdin, stdout=stdout)
        return (process.wait(), None if stdout is not subprocess.PIPE else process.communicate()[0].decode('utf-8'))
72967
def exec_pg_success(self, cmd):
        
        result = self.inner().exec_run(cmd, user='postgres')
        assert result.exit_code == 0, result.output.decode('utf-8')
        return result
1256279
def run(self, command, env={}, path=None,
            uid=None, gid=None, usePTY=0, childFDs=None):
        
        deferred = defer.Deferred()
        processProtocol = _SummaryProcessProtocol(deferred)
        d = defer.maybeDeferred(self.execute, processProtocol, command, env,
                                path, uid, gid, usePTY, childFDs)
        d.addErrback(deferred.errback)
        return deferred
1197244
def run_local(self, commands):
        
        process = subprocess.Popen(
            commands.get('cli_command'),
            shell=self.shell,
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )

        out, err = process.communicate()

        # display app output
        self.run_display_app_output(out)
        self.run_display_app_errors(err)

        # Exit Code
        return self.run_exit_code(process.returncode)
850777
def run(command, *args)
      command_name = "lxc-#{command}"

      unless BIN_FILES.include?(command_name)
        raise ArgumentError, "Invalid command: #{command_name}."
      end

      cmd = ""
      cmd << "sudo " if use_sudo == true
      cmd << "#{command_name} #{args.join(" ")}".strip
      cmd << " | #{yield}" if block_given?

      # Debug if LXC_DEBUG env is set
      if ENV["LXC_DEBUG"]
        puts "Executing: #{cmd}"
      end

      child = POSIX::Spawn::Child.new(cmd.strip)
      child.out
    end
1368733
function spawn(cmd, args, opts) {
  const spawn = require('child_process').spawn;
  const _ = require('lodash');
  return new Promise((resolve, reject) => {
    const p = spawn(cmd, typeof args === 'string' ? args.split(' ') : args, _.merge({stdio: argv.quiet ? ['ignore', 'pipe', 'pipe'] : ['ignore', 1, 2]}, opts));
    const out = [];
    if (p.stdout) {
      p.stdout.on('data', (chunk) => out.push(chunk));
    }
    if (p.stderr) {
      p.stderr.on('data', (chunk) => out.push(chunk));
    }
    p.on('close', (code, signal) => {
      if (code === 0) {
        console.info(cmd, 'ok status code', code, signal);
        resolve(code);
      } else {
        console.error(cmd, 'status code', code, signal);
        if (args.quiet) {
          // log output what has been captured
          console.log(out.join('\n'));
        }
        reject(`${cmd} failed with status code ${code} ${signal}`);
      }
    });
  });
}
174291
function spawnCmd(command, args, options) {
    var d = Promise.defer();
    var child = spawn(command, args, options);

    child.on('error', function(error) {
        return d.reject(error);
    });

    child.stdout.on('data', function (data) {
        d.notify(data);
    });

    child.stderr.on('data', function (data) {
        d.notify(data);
    });

    child.on('close', function(code) {
        if (code === 0) {
            d.resolve();
        } else {
            d.reject(new Error('Error with command "'+command+'"'));
        }
    });

    return d.promise;
}
39584
def run(self):
        

        async def run_command():
            try:
                self.result = self.command(
                    context=self.context,
                    **self.kwargs
                )
            except Exception as error:
                self.exception = error
                print(error)
                import traceback
                traceback.print_exc()
                import sys
                self.context.response.fail(
                    code='COMMAND_EXECUTION_ERROR',
                    message='Failed to execute command due to internal error',
                    error=error
                ).console(
                    whitespace=1
                )

        self._has_started = True
        self._loop = asyncio.new_event_loop()
        self._loop.run_until_complete(run_command())
        self._loop.close()
        self._loop = None
        self.completed_at = datetime.utcnow()
1166137
function runCommand(command, fail, log) {
  return new Promise(function(resolve, reject) {
      if (!command) {
        return resolve('No command found');
      }

      log(command);

      var task = exec(command, {
        cwd: process.cwd()
      }, function(err, stdout, stderr) {
        log(stdout);

        if (err) {
          log(stderr, { color: 'red' });
        }
      });

      task.on('exit', function(code) {
        if (code !== 0 && fail) {
          reject(code);
        }

        resolve(command);
        process.stdin.end();
      });

      process.stdin.pipe(task.stdin, { end: false });
    });
}
400902
function start(cmd, { silent = false, env = null } = {}) {
    const parts = cmd.split(' ');
    const command = parts[0][0] === '.' ? path.resolve(parts[0]) : parts[0];
    const handle = {
        process: child_process_1.spawn(command, parts.slice(1), {
            stdio: silent ? 'pipe' : 'inherit',
            env: env || process.env,
            cwd: process.cwd()
        }),
        promise: Promise.resolve()
    };
    handle.promise = new Promise(function (resolve, reject) {
        let resolved = false;
        handle.process.once('error', error => {
            resolved = true;
            reject(error);
        });
        handle.process.once('exit', (code, signal) => {
            if (resolved)
                return;
            if (code === 0) {
                resolve();
            }
            else {
                signal = signal ? `${signal}:` : '';
                reject(new Error(`Child exited with ${signal}${code}`));
            }
        });
    });
    return Promise.resolve(handle);
}
479025
function spawnExt(command, args, options, ignoreClose = false) {
  let proc;
  const promise = new Promise((resolve, reject) => {
    let descr = command + ' ' + args.join(' ');
    console.log('running: ' + descr);
    try {
      proc = xSpawn.spawn(command, args, options);
    } catch (e) {
      console.log(e);
      reject(e);
      return { proc: null, promise };
    }
    proc.stdout.on('data', function (data) {
      process.stdout.write(data.toString());
    });
    proc.stderr.on('data', function (data) {
      process.stdout.write(data.toString());
    });
    proc.on('close', function (returnCode) {
      console.log(`completed: ${descr} \n`);
      // Many tasks (e.g., tsc) complete but are actually errors;
      // Confirm return code is zero.
      returnCode === 0 || ignoreClose ? resolve(0) : reject(returnCode);
    });
    proc.on('error', function (data) {
      console.log(`completed with error: ${descr} \n`);
      console.log(data.toString());
      reject(data);
    });
  });
  return { proc, promise };
}
1022184
function exec(cmd, args = [], silent = false) {
    return __awaiter(this, void 0, void 0, function* () {
        const response = [];
        return new Promise((resolve, reject) => {
            const exe = child_process_1.spawn(cmd, args, {
                env: process.env
            });
            exe.stdout.on('data', data => {
                response.push(data.toString());
                if (!silent) {
                    console.log(data.toString());
                }
            });
            exe.stderr.on('data', data => {
                if (!silent) {
                    console.error(data.toString());
                }
            });
            exe.on('exit', code => {
                if (code === 0) {
                    return resolve(response);
                }
                else {
                    if (!silent) {
                        console.error('Problem executing ' + cmd);
                    }
                    return reject();
                }
            });
        });
    });
}
756721
function exec(cmd, args, stdin, callback) {
            var stdout = concat();
            var stderr = concat();

            var process = child_process.spawn(cmd, args, {
                stdio: [stdin || 'ignore', 'pipe', 'pipe']
            });
            process.stdout.pipe(stdout);
            process.stderr.pipe(stderr);
            process.on('exit', function(code, signal) {
              var err;
              if (code) {
                err = new Error(code);
                err.code = code;
                err.signal = signal;
              }
              callback(err, stdout, stderr);
            });
            process.on('error', function (err) {
              callback(err, stdout, stderr);
            });
        }
1093772
def execute(self, processProtocol, command, env={},
                path=None, uid=None, gid=None, usePTY=0, childFDs=None):
        
        raise NotImplementedError()
369618
function exec (cmd) {

        var deferred = Q.defer();

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

        return deferred.promise;

    }