Writes command prompt and waits for command request from user.
<p>

@param r input reader
@return array with command and command arguments
@throws IOException on I/O error
490309
private String[] readLine(BufferedReader r) throws IOException
	{
		System.out.print("> ");
		final String line = r.readLine();
		return line != null ? split(line) : null;
	}
932727
public String[][] getList(final Reader r) throws IOException {
    try {
      setReader(r);
      reset();
      String[][] result = tokenCollection.getList();
      end();
      close();
      return result;
    } catch (MtasParserException e) {
      log.info(e);
      throw new IOException("can't produce list");
    }
  }
1034290
public static ArrayList<String> runProcess(String... commands)
      throws InterruptedException, IOException {
    final java.lang.ProcessBuilder processBuilder = new java.lang.ProcessBuilder(commands);
    final ArrayList<String> output = new ArrayList<>();
    final Process process = processBuilder.start();
    process.waitFor();
    final InputStream inputStream = process.getInputStream();
    try {
      final java.io.BufferedReader reader = new java.io.BufferedReader(
          new InputStreamReader(inputStream, StandardCharsets.UTF_8));
      String line;
      while ((line = reader.readLine()) != null) {
        output.add(line);
      }
    } finally {
      inputStream.close();
    }
    return output;
  }
1370007
def write(self, cmd='AT'):
        """"""
        self.cmd_response = ''
        self.cmd_responselines = []
        if self.ser is None:
            return 0
        cmd += '\r\n'
        return self.ser.write(cmd.encode())
94285
static public IParserInput getInstance(
            final char commandPrefix,
            final File args)
                    throws IOException
    {
        return getInstance(commandPrefix, false, args);
    }
759083
public boolean sendCommand(String command) {
        if (writer != null) {
            try {
                logger.info("Sending command " + command + " to remote host " + remoteHost);
                writer.write(command);
                writer.write('\r');
                writer.flush();
            } catch (IOException e) {
                logger.fatal("Error while sending command " + command + " to remote host " + remoteHost, e);
                return false;
            }
            return true;
        } else {
            return false;
        }
    }
1238118
@Override
    public void write(char[] cbuf, int off, int len) throws IOException {
        try {
            String indexedHash =
                    RmiJournalReceiverHelper.figureIndexedHash(repositoryHash,
                                                               itemIndex);
            receiver.writeText(indexedHash, new String(cbuf, off, len));
            itemIndex++;
        } catch (JournalException e) {
            throw new IOException(e);
        }
    }
53769
public void importFrom(Reader r) {
        BufferedReader reader = new BufferedReader(r);
        String s;
        
        Iterator<String> iter = 
            new RegexLineIterator(
                    new LineReadingIterator(reader),
                    RegexLineIterator.COMMENT_LINE,
                    RegexLineIterator.NONWHITESPACE_ENTRY_TRAILING_COMMENT,
                    RegexLineIterator.ENTRY);

        while (iter.hasNext()) {
            s = (String) iter.next();
            add(s.toLowerCase());
        }
    }
846475
public void print(final Reader r) throws MtasParserException {
    try {
      setReader(r);
      reset();
      if (tokenCollection != null) {
        tokenCollection.print();
      }
      end();
      close();
    } catch (IOException e) {
      log.error(e);
      throw new MtasParserException(e.getClass() + " : " + e.getMessage());
    }
  }
1357868
private Process launch() throws IOException {
		StringBuilder command = new StringBuilder(12 + (parameters.size() << 3));
		command.append(this.driver.getCommand()).append(" ");
		for (Entry<String, String> entry : parameters.entrySet()) {
			command.append("--").append(entry.getKey()).append(" ");
			if (entry.getValue() != null) {
				command.append(entry.getValue()).append(" ");
			}
		}

		String commandString = command.toString();
		if (LOGGER.isDebugEnabled()) {
			LOGGER.debug(commandString);
		}
		return Runtime.getRuntime().exec(commandString);
	}
40049
public void execute() {
    try {
      Command command = new Parser().parse();
      try {
        command.execute(new ContextImpl(), execute);
        close();
      } catch (Exception e) {
        throw new RuntimeException(
            "Error while executing command " + command, e);
      } catch (AssertionError e) {
        throw new RuntimeException(
            "Error while executing command " + command, e);
      }
    } finally {
      try {
        reader.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
      writer.close();
      try {
        close();
      } catch (SQLException e) {
        // ignore
      }
    }
  }
842821
public int exec() throws IOException {
        int exitValue = 0;
        List<String> argl = new ArrayList<String>();
        argl.add(executable.toString());
        for (Object a : args) {
            if (a != null) {
                if (a.getClass() == String.class) {
                    argl.add(a.toString());
                } else if (a.getClass() == String[].class) {
                    for (String s : (String[]) a) {
                        if (s != null && !s.isEmpty()) {
                            argl.add(s);
                        }
                    }
                }
            }
        }

        pb.command(argl);
        if (log != null && log.isLoggable(Level.INFO)) {
            log.info("Command : " + pb.command().toString());
        }

        Process process = pb.start();
        CountDownLatch latch = new CountDownLatch(2);

//        Thread in_ = new Thread(new Handler(stdin,
//                new OutputStreamWriter(process.getOutputStream()), latch));
        Thread out_ = new Thread(new Handler(new BufferedReader(
                new InputStreamReader(process.getInputStream())), stdout, latch));
        Thread err_ = new Thread(new Handler(new BufferedReader(
                new InputStreamReader(process.getErrorStream())), stderr, latch));

        out_.start();
        err_.start();
//        in_.start();

        try {
            latch.await();
            exitValue = process.waitFor();
        } catch (InterruptedException e) {
//            throw new RuntimeException(e);
        } finally {
            process.getInputStream().close();
            process.getOutputStream().close();
            process.getErrorStream().close();
            process.destroy();
        }
        return exitValue;
    }
531329
private static String[] executeShellCommand(String[] command)
  throws IOException {
    String groups = Shell.execCommand(command);
    StringTokenizer tokenizer = new StringTokenizer(groups);
    int numOfTokens = tokenizer.countTokens();
    String[] tokens = new String[numOfTokens];
    for (int i=0; tokenizer.hasMoreTokens(); i++) {
      tokens[i] = tokenizer.nextToken();
    }

    return tokens;
  }
1222007
public List<String> flushStdout() throws IOException {
		List<String> result = new ArrayList<String>();
		while(stdout.ready()) {
			result.add(stdout.readLine());
		}
		return result;
	}
444819
@SuppressWarnings("unchecked")
        public static void executeCommand(String[] args) throws IOException {

            OptionParser parser = getParser();

            // declare parameters
            List<String> metaKeys = null;
            String url = null;
            String dir = null;
            List<Integer> nodeIds = null;
            Boolean allNodes = true;
            Boolean verbose = false;

            // parse command-line input
            args = AdminToolUtils.copyArrayAddFirst(args, "--" + OPT_HEAD_META_GET);
            OptionSet options = parser.parse(args);
            if(options.has(AdminParserUtils.OPT_HELP)) {
                printHelp(System.out);
                return;
            }

            // check required options and/or conflicting options
            AdminParserUtils.checkRequired(options, OPT_HEAD_META_GET);
            AdminParserUtils.checkRequired(options, AdminParserUtils.OPT_URL);
            AdminParserUtils.checkOptional(options,
                                           AdminParserUtils.OPT_NODE,
                                           AdminParserUtils.OPT_ALL_NODES);

            // load parameters
            metaKeys = (List<String>) options.valuesOf(OPT_HEAD_META_GET);
            url = (String) options.valueOf(AdminParserUtils.OPT_URL);
            if(options.has(AdminParserUtils.OPT_DIR)) {
                dir = (String) options.valueOf(AdminParserUtils.OPT_DIR);
            }
            if(options.has(AdminParserUtils.OPT_NODE)) {
                nodeIds = (List<Integer>) options.valuesOf(AdminParserUtils.OPT_NODE);
                allNodes = false;
            }
            if(options.has(OPT_VERBOSE)) {
                verbose = true;
            }

            // execute command
            File directory = AdminToolUtils.createDir(dir);
            AdminClient adminClient = AdminToolUtils.getAdminClient(url);

            if(allNodes) {
                nodeIds = AdminToolUtils.getAllNodeIds(adminClient);
            }

            if(metaKeys.size() == 1 && metaKeys.get(0).equals(METAKEY_ALL)) {
                metaKeys = Lists.newArrayList();
                for(Object key: MetadataStore.METADATA_KEYS) {
                    metaKeys.add((String) key);
                }
            }

            doMetaGet(adminClient, nodeIds, metaKeys, directory, verbose);
        }
583509
public Response execute(Command command) throws IOException {
        for (EventListener temp : listeners) {
            temp.beforeEvent(command);
        }
        Response res = commandExecutor.execute(command);

        for (EventListener temp : listeners) {
            temp.afterEvent(command);
        }

        return res;
    }
614272
@Override
    public Object read(JSONReader r, JsonParser p) throws IOException
    {
        if (p.isExpectedStartObjectToken()) {
            final Object bean;
            try {
                bean = create();
            } catch (Exception e) {
                return _reportFailureToCreate(p, e);
            }
            p.setCurrentValue(bean);
            return _readBean(r, p, bean);
        }
        try {
            switch (p.currentTokenId()) {
            case JsonTokenId.ID_NULL:
                return null;
            case JsonTokenId.ID_STRING:
                return create(p.getText());
            case JsonTokenId.ID_NUMBER_INT:
                return create(p.getLongValue());
            default:
            }
        } catch (Exception e) {
            return _reportFailureToCreate(p, e);
        }
        throw JSONObjectException.from(p, "Can not create a %s instance out of %s",
                _type.getName(), _tokenDesc(p));
    }