Return a command line list compatible with ProcessBuilder.command()
344571
public List<String> createCommandLine() {
        List<String> cmdline = new ArrayList<>(50);
        cmdline.add(javaExecutable);
        cmdline.add("-XX:+HeapDumpOnOutOfMemoryError");
        cmdline.add("-Dsun.net.inetaddr.ttl=300");
        cmdline.add("-Dsun.net.inetaddr.negative.ttl=3600");
        cmdline.add("-Djava.library.path=" + java_library_path);
        /*
         * Facilitate SPNEGO (Kerberos HTTP) authentication
         */
        cmdline.add("-Djavax.security.auth.useSubjectCredsOnly=false");

        if (rmi_host_name != null) {
            cmdline.add("-Djava.rmi.server.hostname=" + rmi_host_name);
        }
        cmdline.add("-Dlog4j.configuration=" + log4j);
        if (m_vemTag != null) {
            cmdline.add("-D" + VEM_TAG_PROPERTY + "=" + m_vemTag);
        }
        if (gcRollover) {
            cmdline.add("-Xloggc:"+ volt_root + "/" + VEM_GC_ROLLOVER_FILE_NAME+" -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles="+VEM_GC_ROLLOVER_FILE_COUNT+" -XX:GCLogFileSize="+VEM_GC_ROLLOVER_FILE_SIZE);
        }
        cmdline.add(maxHeap);
        cmdline.add("-XX:+UseConcMarkSweepGC");
        cmdline.add("-XX:+CMSParallelRemarkEnabled");
        cmdline.add("-XX:+UseTLAB");
        cmdline.add("-XX:CMSInitiatingOccupancyFraction=75");
        cmdline.add("-XX:+UseCMSInitiatingOccupancyOnly");
        cmdline.add("-XX:+CMSClassUnloadingEnabled");

        /*
         * Have RMI not invoke System.gc constantly
         */
        cmdline.add("-Dsun.rmi.dgc.server.gcInterval=" + Long.MAX_VALUE);
        cmdline.add("-Dsun.rmi.dgc.client.gcInterval=" + Long.MAX_VALUE);
        /*
         * To ensure that CMS is low pause on a consistent basis, have it wait a looong time
         * for young gen GCs to occur when load is low. Scavenge before remark
         * so when remarks occur they are a consistent duration.
         */
        cmdline.add("-XX:CMSWaitDuration=120000");
        cmdline.add("-XX:CMSMaxAbortablePrecleanTime=120000");
        cmdline.add("-XX:+ExplicitGCInvokesConcurrent");
        cmdline.add("-XX:+CMSScavengeBeforeRemark");
        //If a Volt root is provided such as local cluster or VEM, put the error file in it
        if ( !volt_root.isEmpty() ) {
            cmdline.add("-XX:ErrorFile=" + volt_root + "/hs_err_pid%p.log");
        }
        if (conditionalCardMark) {
            cmdline.add("-XX:+UseCondCardMark");
        }
        cmdline.add("-classpath"); cmdline.add(classPath);

        if (includeTestOpts)
        {
            cmdline.add("-DLOG_SEGMENT_SIZE=8");
            if (!m_newCli) {
                cmdline.add("-DVoltFilePrefix=" + voltFilePrefix);
            }
            cmdline.add("-ea");
            cmdline.add("-XX:MaxDirectMemorySize=2g");
        }
        else
        {
            cmdline.add("-server");
            cmdline.add("-XX:HeapDumpPath=/tmp");
            if (!initialHeap.isEmpty()) {
                cmdline.add(initialHeap);
                cmdline.add("-XX:+AlwaysPreTouch");
            }
        }

        if (m_isEnterprise)
        {
            cmdline.add("-Dvolt.rmi.agent.port=" + jmxPort);
            cmdline.add("-Dvolt.rmi.server.hostname=" + jmxHost);
        }

        // add default keystore, truststore
        if (m_sslEnable) {
            cmdline.add("-Djavax.net.ssl.keyStore=tests/frontend/org/voltdb/keystore");
            cmdline.add("-Djavax.net.ssl.keyStorePassword=password");
            cmdline.add("-Djavax.net.ssl.trustStore=tests/frontend/org/voltdb/keystore");
            cmdline.add("-Djavax.net.ssl.trustStorePassword=password");
        }


        if (javaProperties != null) {
            for (Entry<String, String> e : javaProperties.entrySet()) {
                if (e.getValue() != null) {
                    cmdline.add("-D" + e.getKey() + "=" + e.getValue());
                }
                else {
                    cmdline.add("-D" + e.getKey());
                }
            }
        }

        if (debugPort > -1) {
            cmdline.add("-Xdebug");
            cmdline.add("-agentlib:jdwp=transport=dt_socket,address=" + debugPort + ",server=y,suspend=n");
        }


        //
        // Process JVM options passed through the VOLTDB_OPTS environment variable
        //
        List<String> additionalJvmOptions = new ArrayList<>();
        String nonJvmOptions = AdditionalJvmOptionsProcessor
                .getJvmOptionsFromVoltDbOptsEnvironmentVariable(additionalJvmOptions);
        cmdline.addAll(additionalJvmOptions);


        //
        // VOLTDB main() parameters
        //
        cmdline.add("org.voltdb.VoltDB");
        cmdline.add(m_startAction.verb());

        if (m_startAction == StartAction.PROBE && m_safeMode) {
            cmdline.add("safemode");
        }

        if (m_startAction == StartAction.PROBE && m_enableAdd) {
            cmdline.add("enableadd");
        }

        if (m_sslEnable) {
            cmdline.add("enableSSL");
        }

        if (m_sslExternal) {
            cmdline.add("externalSSL");
        }

        if (m_sslInternal) {
            cmdline.add("internalSSL");
        }

        cmdline.add("host");
        if (!m_coordinators.isEmpty()) {
            cmdline.add(Joiner.on(',').skipNulls().join(m_coordinators));
        } else {
            cmdline.add(m_leader);
        }
        if (jarFileName() != null) {
            cmdline.add("catalog"); cmdline.add(jarFileName());
        }
        //Add deployment if its not probe
        if (pathToDeployment() != null && m_startAction != StartAction.PROBE) {
            cmdline.add("deployment"); cmdline.add(pathToDeployment());
        }

        if (includeTestOpts)
        {
            cmdline.add("timestampsalt"); cmdline.add(Long.toString(m_timestampTestingSalt));
        }

        cmdline.add("port"); cmdline.add(Integer.toString(m_port));
        cmdline.add("internalport"); cmdline.add(Integer.toString(m_internalPort));
        if (m_adminPort != -1)
        {
            cmdline.add("adminport"); cmdline.add(Integer.toString(m_adminPort));
        }
        if (zkport != -1)
        {
            cmdline.add("zkport"); cmdline.add(Integer.toString(zkport));
        }
        if (m_drAgentPortStart != -1)
        {
            cmdline.add("replicationport"); cmdline.add(Integer.toString(m_drAgentPortStart));
        }
        if (m_drPublicHost != null || m_drPublicPort != VoltDB.DISABLED_PORT) {
            cmdline.add("drpublic");
            String param = (m_drPublicHost != null && !m_drPublicHost.isEmpty()) ? m_drPublicHost : "";
            if (m_drPublicPort != VoltDB.DISABLED_PORT) {
                param = (param.isEmpty()) ? Integer.toString(m_drPublicPort)
                                          : param + ":" + Integer.toString(m_drPublicPort);
            }
            cmdline.add(param);
        }

        if (target() == BackendTarget.NATIVE_EE_VALGRIND_IPC) {
            cmdline.add("valgrind");
        }

        if (m_internalInterface != null && !m_internalInterface.isEmpty())
        {
            cmdline.add("internalinterface"); cmdline.add(m_internalInterface);
        }

        if (m_internalInterface != null && (m_externalInterface != null && !m_externalInterface.isEmpty()))
        {
            cmdline.add("externalinterface"); cmdline.add(m_externalInterface);
        }
        if (m_httpPort != Constants.HTTP_PORT_DISABLED) {
            cmdline.add("httpport"); cmdline.add(Integer.toString(m_httpPort));
        }

        if (m_forceVoltdbCreate)
        {
            cmdline.add("force");
        }

        if (m_isEnterprise) {
            cmdline.add("license"); cmdline.add(m_pathToLicense);
        }

        if (m_userSchemas != null) {
            cmdline.add("schema");
            cmdline.add(m_userSchemas.stream().map(File::getAbsolutePath).collect(Collectors.joining(",")));
        }

        if (customCmdLn != null && !customCmdLn.trim().isEmpty())
        {
            cmdline.add(customCmdLn);
        }
        //
        // append non JVM options from the value of the VOLTDB_OPTIONS
        // environment variable to customCmdLn
        //
        if( nonJvmOptions != null && !nonJvmOptions.trim().isEmpty())
        {
            cmdline.add(nonJvmOptions);
        }

        if (m_backend.isIPC) {
            cmdline.add("ipcport");
            cmdline.add(String.valueOf(m_ipcPort));
        }

        if (target() == BackendTarget.NATIVE_EE_IPC) {
            cmdline.add("ipc");
        }

        if (m_tag != null) {
            cmdline.add("tag"); cmdline.add(m_tag);
        }

        // handle overrides for testing hotfix version compatibility
        if (m_versionStringOverrideForTest != null) {
            assert(m_versionCompatibilityRegexOverrideForTest != null);
            cmdline.add("versionoverride");
            cmdline.add(m_versionStringOverrideForTest);
            cmdline.add(m_versionCompatibilityRegexOverrideForTest);
            if (m_buildStringOverrideForTest != null) {
                cmdline.add("buildstringoverride");
                cmdline.add(m_buildStringOverrideForTest);
            }
        }
        if (m_isPaused || (m_modeOverrideForTest != null && m_modeOverrideForTest.equalsIgnoreCase("paused")) ) {
            cmdline.add("paused");
        }

        //Add mesh and hostcount for probe only.
        if (m_startAction == StartAction.PROBE) {
            cmdline.add("mesh"); cmdline.add(Joiner.on(',').skipNulls().join(m_coordinators));
            cmdline.add("hostcount"); cmdline.add(Integer.toString(m_hostCount));
        }

        if (!m_startAction.isLegacy()) {
            cmdline.add("voltdbroot"); cmdline.add(m_voltdbRoot.getPath());
        }

        if (m_placementGroup != null) {
            cmdline.add("placementgroup"); cmdline.add(m_placementGroup);
        }

        if ( m_missingHostCount > 0) {
            cmdline.add("missing"); cmdline.add(Integer.toString(m_missingHostCount));
        }
        return cmdline;
    }
948887
private List<String> collectProcessResults(Process process, ProcessBuilder builder,
      SubProcessIOFiles outPutFiles) throws Exception {

    List<String> results = new ArrayList<>();

    try {

      LOG.debug(String.format("Executing process %s", createLogEntryFromInputs(builder.command())));

      // If process exit value is not 0 then subprocess failed, record logs
      if (process.exitValue() != 0) {
        outPutFiles.copyOutPutFilesToBucket(configuration, FileUtils.toStringParams(builder));
        String log = createLogEntryForProcessFailure(process, builder.command(), outPutFiles);
        throw new Exception(log);
      }

      // If no return file then either something went wrong or the binary is setup incorrectly for
      // the ret file either way throw error
      if (!Files.exists(outPutFiles.resultFile)) {
        String log = createLogEntryForProcessFailure(process, builder.command(), outPutFiles);
        outPutFiles.copyOutPutFilesToBucket(configuration, FileUtils.toStringParams(builder));
        throw new Exception(log);
      }

      // Everything looks healthy return values
      try (Stream<String> lines = Files.lines(outPutFiles.resultFile)) {
        for (String line : (Iterable<String>) lines::iterator) {
          results.add(line);
        }
      }
      return results;
    } catch (Exception ex) {
      String log = String.format("Unexpected error runnng process. %s error message was %s",
          createLogEntryFromInputs(builder.command()), ex.getMessage());
      throw new Exception(log);
    }
  }
581831
public static List<String> constructCommandAsList_Windows_cmd (String command) {
		List<String> commandAsList = new ArrayList<String> ();

		commandAsList.add ("cmd");
		commandAsList.add ("/c");
		commandAsList.add (command);

		return commandAsList;
	}
650753
private String executeCommand() throws IOException, InterruptedException {
        ProcessBuilder processBuilder = new ProcessBuilder(command);

        ByteArrayOutputStream commandOutput = new ByteArrayOutputStream();

        Process process = processBuilder.start();
        try {
            IOUtils.copy(process.getInputStream(), commandOutput, processOutputLimit);

            process.waitFor();

            if (process.exitValue() != 0) {
                throw new IllegalStateException("Command returned non-zero exit value: " + process.exitValue());
            }

            return new String(commandOutput.toByteArray(), StringUtils.UTF8);
        } finally {
            process.destroy();
        }
    }
774574
private List<SourceFile> getBuiltinExterns(CompilerOptions options) {
    try {
      return CommandLineRunner.getBuiltinExterns(options.getEnvironment());
    } catch (IOException e) {
      throw new BuildException(e);
    }
  }
183137
private void processCommand(List<String> command) throws Exception {
        processBuilder.command(command);
        Process p = processBuilder.start();
        checkReturnCode(p, processBuilder.command().toString(), ReturnCode.OK.getValue(), ReturnCode.ALREADY_EXISTS.getValue());
        if (!acceptLicense) {
            throw new BuildException("To install a feature, you must accept the feature's license terms and conditions.");
        }
    }
132552
def raw_cmd(self, *args):
        ''''''
        cmd_line = [self.adb()] + self.adb_host_port_options + list(args)
        if os.name != "nt":
            cmd_line = [" ".join(cmd_line)]
        return subprocess.Popen(cmd_line, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
389674
function buildProcessOptions(processes, logRoot, cmdOptions) {
  return _.flatten(_.map(_.keys(processes), function(procKey) {
    var concurrentCount = parser.parseConcurrencyOpts(cmdOptions)[procKey] || 1;
    return _.map(_.range(concurrentCount), function(index) {
      return {
	id: getID(procKey, index),
	user: cmdOptions.user,
	port: cmdOptions.port,
	processCommand: processes[procKey],
	logRoot: logRoot,
	processName: procKey,
	num: index
      };
    });
  }));
}
372734
void run(List<String> arguments, @Nullable Path workingDirectory)
      throws ProcessHandlerException, CloudSdkNotFoundException, CloudSdkOutOfDateException,
          CloudSdkVersionFileException, IOException {

    sdk.validateCloudSdk();

    List<String> command = new ArrayList<>();
    command.add(sdk.getGCloudPath().toAbsolutePath().toString());

    command.addAll(arguments);
    if (outputFormat != null) {
      command.addAll(GcloudArgs.get("format", outputFormat));
    }

    if (credentialFile != null) {
      command.addAll(GcloudArgs.get("credential-file-override", credentialFile));
    }

    logger.info("submitting command: " + Joiner.on(" ").join(command));

    ProcessBuilder processBuilder = processBuilderFactory.newProcessBuilder();
    processBuilder.command(command);
    if (workingDirectory != null) {
      processBuilder.directory(workingDirectory.toFile());
    }
    processBuilder.environment().putAll(getGcloudCommandEnvironment());
    Process process = processBuilder.start();
    processHandler.handleProcess(process);
  }
690242
public ProcessInfo execute(boolean background,String...  command)
	{
		 ProcessBuilder pb = new ProcessBuilder(command);

		 
		return executeProcess(background,pb);
		
	}
303561
private static List<String> buildCommand(File fatJar) {
        List<String> command = new ArrayList<>(Collections.singleton(javaCommand()));

        command.addAll(properties());
        command.addAll(asList(
                FatJarBuilder.class.getCanonicalName(),
                fatJar.getAbsolutePath()
        ));
        return command;
    }
144164
public List<ProcessInstance> executeList(CommandContext commandContext, Map<String, Object> parameterMap, int firstResult, int maxResults) {
    return commandContext.getExecutionEntityManager().findProcessInstanceByNativeQuery(parameterMap, firstResult, maxResults);
  }
62053
def commandline_to_list(self, cmdline_str, trigger_string):
        '''
        
        '''
        cmdline = salt.utils.args.shlex_split(cmdline_str[len(trigger_string):])
        # Remove slack url parsing
        #  Translate target=<http://host.domain.net|host.domain.net>
        #  to target=host.domain.net
        cmdlist = []
        for cmditem in cmdline:
            pattern = r'(?P<begin>.*)(<.*\|)(?P<url>.*)(>)(?P<remainder>.*)'
            mtch = re.match(pattern, cmditem)
            if mtch:
                origtext = mtch.group('begin') + mtch.group('url') + mtch.group('remainder')
                cmdlist.append(origtext)
            else:
                cmdlist.append(cmditem)
        return cmdlist
315905
def cli(self, commands):
        """"""
        cli_output = {}

        def _count(txt, none):  # Second arg for consistency only. noqa
            """
            Return the exact output, as Junos displays
            e.g.:
            > show system processes extensive | match root | count
            Count: 113 lines
            """
            count = len(txt.splitlines())
            return "Count: {count} lines".format(count=count)

        def _trim(txt, length):
            """
            Trim specified number of columns from start of line.
            """
            try:
                newlines = []
                for line in txt.splitlines():
                    newlines.append(line[int(length) :])
                return "\n".join(newlines)
            except ValueError:
                return txt

        def _except(txt, pattern):
            """
            Show only text that does not match a pattern.
            """
            rgx = "^.*({pattern}).*$".format(pattern=pattern)
            unmatched = [
                line for line in txt.splitlines() if not re.search(rgx, line, re.I)
            ]
            return "\n".join(unmatched)

        def _last(txt, length):
            """
            Display end of output only.
            """
            try:
                return "\n".join(txt.splitlines()[(-1) * int(length) :])
            except ValueError:
                return txt

        def _match(txt, pattern):
            """
            Show only text that matches a pattern.
            """
            rgx = "^.*({pattern}).*$".format(pattern=pattern)
            matched = [line for line in txt.splitlines() if re.search(rgx, line, re.I)]
            return "\n".join(matched)

        def _find(txt, pattern):
            """
            Search for first occurrence of pattern.
            """
            rgx = "^.*({pattern})(.*)$".format(pattern=pattern)
            match = re.search(rgx, txt, re.I | re.M | re.DOTALL)
            if match:
                return "{pattern}{rest}".format(pattern=pattern, rest=match.group(2))
            else:
                return "\nPattern not found"

        def _process_pipe(cmd, txt):
            """
            Process CLI output from Juniper device that
            doesn't allow piping the output.
            """
            if txt is None:
                return txt
            _OF_MAP = OrderedDict()
            _OF_MAP["except"] = _except
            _OF_MAP["match"] = _match
            _OF_MAP["last"] = _last
            _OF_MAP["trim"] = _trim
            _OF_MAP["count"] = _count
            _OF_MAP["find"] = _find
            # the operations order matter in this case!
            exploded_cmd = cmd.split("|")
            pipe_oper_args = {}
            for pipe in exploded_cmd[1:]:
                exploded_pipe = pipe.split()
                pipe_oper = exploded_pipe[0]  # always there
                pipe_args = "".join(exploded_pipe[1:2])
                # will not throw error when there's no arg
                pipe_oper_args[pipe_oper] = pipe_args
            for oper in _OF_MAP.keys():
                # to make sure the operation sequence is correct
                if oper not in pipe_oper_args.keys():
                    continue
                txt = _OF_MAP[oper](txt, pipe_oper_args[oper])
            return txt

        if not isinstance(commands, list):
            raise TypeError("Please enter a valid list of commands!")
        _PIPE_BLACKLIST = ["save"]
        # Preprocessing to avoid forbidden commands
        for command in commands:
            exploded_cmd = command.split("|")
            command_safe_parts = []
            for pipe in exploded_cmd[1:]:
                exploded_pipe = pipe.split()
                pipe_oper = exploded_pipe[0]  # always there
                if pipe_oper in _PIPE_BLACKLIST:
                    continue
                pipe_args = "".join(exploded_pipe[1:2])
                safe_pipe = (
                    pipe_oper
                    if not pipe_args
                    else "{fun} {args}".format(fun=pipe_oper, args=pipe_args)
                )
                command_safe_parts.append(safe_pipe)
            safe_command = (
                exploded_cmd[0]
                if not command_safe_parts
                else "{base} | {pipes}".format(
                    base=exploded_cmd[0], pipes=" | ".join(command_safe_parts)
                )
            )
            raw_txt = self.device.cli(safe_command, warning=False)
            cli_output[py23_compat.text_type(command)] = py23_compat.text_type(
                _process_pipe(command, raw_txt)
            )
        return cli_output
958463
def run(cmd, *args, **kwargs):
    """"""
    log.info('> ' + list2cmdline(cmd))
    kwargs.setdefault('cwd', here)
    kwargs.setdefault('shell', sys.platform == 'win32')
    if not isinstance(cmd, list):
        cmd = cmd.split()
    return check_call(cmd, *args, **kwargs)
303928
def _output_to_list(cmdoutput):
    '''
    
    '''
    return [item for line in cmdoutput.splitlines() if _safe_output(line) for item in line.split()]
355221
private void execCommand(String command,List args) 
		throws NoSuchMethodException,IllegalAccessException,InvocationTargetException
	{
		Class[] template = new Class[ args.size() ];
		for (int i=0; i<args.size(); i++) {
			template[i] = String.class;
		}
		Method m = MatchExptScript.class.getMethod(command, template );
		m.invoke(this, args.toArray(new String[0]));
	}