Command 'supervisord shell' runs the interactive command shell.
515530
def _handle_shell(self,cfg_file,*args,**options):
        """"""
        args = ("--interactive",) + args
        return supervisorctl.main(("-c",cfg_file) + args)
1361409
def run_manage_command(self, command, venv_path, verbose=True):
        
        self.logger.debug('Running manage command `%s` for `%s` ...' % (command, venv_path))
        self._run_shell_command(
            '. %s/bin/activate && python %s %s' % (venv_path, self._get_manage_py_path(), command),
            pipe_it=(not verbose))
772391
function runCmd(cmd, args, fn) {
    args = args || [];
    let runner = require('child_process').spawn(cmd, args, {
        // keep color
        stdio: 'inherit',
    });
    runner.on('close', function(code) {
        if (fn) {
            fn(code);
        }
    });
}
1243759
def run_command(self, args=None, node_paths=None):
    """"""
    return command_gen(
      self.tool_installations,
      self.name,
      args=args,
      node_paths=node_paths
    )
647754
public static void runShellCommand(String[] cmd,
                                     StringBuilder outputLines)
    throws IOException {
    runShellCommand(cmd, outputLines, null);
  }
915662
def run(self, bin, *args, **kwargs):
        
        bin = self._bin(bin)

        cmd = [bin] + list(args)
        shell = kwargs.get("shell", False)
        call = kwargs.pop("call", False)
        input_ = kwargs.pop("input_", None)

        if shell:
            cmd = list_to_shell_command(cmd)

        try:
            if self._is_windows:
                kwargs["shell"] = True

            if input_:
                p = subprocess.Popen(
                    cmd,
                    stdin=subprocess.PIPE,
                    stdout=subprocess.PIPE,
                    stderr=subprocess.STDOUT,
                    **kwargs
                )
                output = p.communicate(encode(input_))[0]
            elif call:
                return subprocess.call(cmd, stderr=subprocess.STDOUT, **kwargs)
            else:
                output = subprocess.check_output(
                    cmd, stderr=subprocess.STDOUT, **kwargs
                )
        except CalledProcessError as e:
            raise EnvCommandError(e)

        return decode(output)
732599
def execute_command(self):
        
        stderr = ""
        role_count = 0
        for role in utils.roles_dict(self.roles_path):
            self.command = self.command.replace("%role_name", role)
            (_, err) = utils.capture_shell("cd {0} && {1}".
                                           format(os.path.join(
                                                  self.roles_path, role),
                                                  self.command))

            stderr = err
            role_count += 1

        utils.exit_if_no_roles(role_count, self.roles_path)

        if len(stderr) > 0:
            ui.error(c.MESSAGES["run_error"], stderr[:-1])
        else:
            if not self.config["options_quiet"]:
                ui.ok(c.MESSAGES["run_success"].replace(
                    "%role_count", str(role_count)), self.options.command)
752604
def start(client, container, interactive=True, stdout=None, stderr=None, stdin=None, **kwargs):
    

    PseudoTerminal(client, container, interactive=interactive, stdout=stdout, stderr=stderr, stdin=stdin).start(**kwargs)
1232449
def run(self, default=None):
        
        parent, *sys_args = sys.argv
        self.parent = Path(parent).stem
        cmd_name = default
        if sys_args:
            cmd_name, *sys_args = sys_args

        if cmd_name is None or cmd_name.lstrip("-") in HELP_COMMANDS:
            self.show_help_root()
            return

        command = self.commands.get(cmd_name)
        if command is None:
            self.show_error(f"command `{cmd_name}` not found")
            self.show_help_root()
            return

        args, opts = parse_args(sys_args)
        return command.run(*args, **opts)
313029
public function interactive()
    {
        echo "welcome! please input command('quit' or 'exit' to Quit).\n ";

        while (true) {
            echo '> ';
            if ($cmd = trim(fgets(\STDIN))) {
                // echo "input command: $cmd\n";
                if ($cmd === 'quit' || $cmd === 'exit') {
                    echo "Quit. Bye\n";
                    break;
                }

                echo $this->command($cmd) . PHP_EOL;
            }

            usleep(50000);
        }

        $this->close();
    }
1271231
def eval_command(self, cmd):
        
        if cmd == 'restart':
            self.restart(soft=True)
        elif cmd == 'stop':
            self.stop()
1103939
def _run_shell_command(self, command, pipe_it=True):
        
        stdout = None
        if pipe_it:
            stdout = PIPE
        self.logger.debug('Executing shell command: %s' % command)
        return not bool(Popen(command, shell=True, stdout=stdout).wait())
675636
def interactive_shell(self, command=None, paster=False, detach=False):
        
        if not exists(self.target + '/.bash_profile'):
            # this file is required for activating the virtualenv
            self.create_bash_profile()

        if not command:
            command = []
        use_tty = sys.stdin.isatty() and sys.stdout.isatty()

        background = environ.get('CIRCLECI', False) or detach

        if is_boot2docker():
            venv_volumes = ['--volumes-from', self._get_container_name('venv')]
        else:
            venv_volumes = ['-v', self.datadir + '/venv:/usr/lib/ckan:rw']

        self._create_run_ini(self.port, production=False, output='run.ini')
        self._create_run_ini(self.port, production=True, output='test.ini',
                             source='ckan/test-core.ini', override_site_url=False)

        script = scripts.get_script_path('shell.sh')
        if paster:
            script = scripts.get_script_path('paster.sh')
            if command and command != ['help'] and command != ['--help']:
                command += ['--config=/project/development.ini']
            command = [self.extension_dir] + command

        proxy_settings = self._proxy_settings()
        if proxy_settings:
            venv_volumes += ['-v',
                             self.sitedir + '/run/proxy-environment:/etc/environment:ro']

        links = {self._get_container_name('solr'): 'solr',
                 self._get_container_name('postgres'): 'db'}

        links.update({self._get_container_name(container): container for container
                      in self.extra_containers})

        link_params = []

        for link in links:
            link_params.append('--link')
            link_params.append(link + ':' + links[link])

        if 'datapusher' in self.containers_running():
            link_params.append('--link')
            link_params.append(self._get_container_name('datapusher') + ':datapusher')

        # FIXME: consider switching this to dockerpty
        # using subprocess for docker client's interactive session
        return subprocess.call([
            DOCKER_EXE, 'run',
            ] + (['--rm'] if not background else []) + [
            '-t' if use_tty else '',
            '-d' if detach else '-i',
            ] + venv_volumes + [
            '-v', self.target + ':/project:rw',
            '-v', self.sitedir + '/files:/var/www/storage:rw',
            '-v', script + ':/scripts/shell.sh:ro',
            '-v', scripts.get_script_path('paster_cd.sh') + ':/scripts/paster_cd.sh:ro',
            '-v', self.sitedir + '/run/run.ini:/project/development.ini:ro',
            '-v', self.sitedir +
                '/run/test.ini:/project/ckan/test-core.ini:ro'] +
            link_params +
            ['--hostname', self.name,
            'datacats/web', '/scripts/shell.sh'] + command)
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()
584670
def process_shell_command
      command_line.set_prompt ':!'
      cmd = command_line.get_command(prompt: ':!')[1..-1]
      execute_external_command pause: true do
        system cmd
      end
    rescue Interrupt
    ensure
      command_line.clear
      command_line.noutrefresh
    end
200003
def exec_command(
        client, container, command, interactive=True, stdout=None, stderr=None, stdin=None):
    
    exec_id = exec_create(client, container, command, interactive=interactive)

    operation = ExecOperation(client, exec_id,
                              interactive=interactive, stdout=stdout, stderr=stderr, stdin=stdin)
    PseudoTerminal(client, operation).start()
319666
def run_shell(cmd, timeout=60, verbose=False):
    """"""
    retcode = None
    try:
        p = Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, executable='/bin/bash')
        continue_running = True
    except Exception as e:
        yield("Failed: %s" % e)
        continue_running = False

    while continue_running:
        try:
            line = p.stdout.readline()
            if verbose and line:
                yield(line)
            elif line.strip():
                yield(line.strip())
        except Exception:
            pass

        try:
            data = irc.recv(4096)
        except Exception as e:
            data = ""
            retcode = p.poll()  # returns None while subprocess is running

        if '!cancel' in data:
            retcode = "Cancelled live output reading. You have to kill the process manually."
            yield "[X]: %s" % retcode
            break

        elif retcode is not None:
            try:
                line = p.stdout.read()
            except:
                retcode = "Too much output, read timed out. Process is still running in background."

            if verbose and line:
                yield line

            if retcode != 0:
                yield "[X]: %s" % retcode
            elif retcode == 0 and verbose:
                yield "[√]"

            break