public boolean is_64(String filep) { ExitStatus status = ProcessUtils.execute(exEnv, "/usr/bin/file", filep); //NOI18N return status.output.contains(" 64"); //NOI18N }
@Override public void run() { try { if (stdout) { ProcessUtils.readProcessError(process); } else { ProcessUtils.readProcessOutput(process); } } catch (Throwable ex) { } } });
@Override public void run() { try { Process p = npb.call(); String comm = ProcessUtils.readProcessOutputLine(p); int rc = p.waitFor(); if (rc != 0) { // No such pid ? stopMonitor(Status.ERROR); return; } if (!collectPattern.matcher(comm).matches()) { stopMonitor(Status.ENABLED); } } catch (InterruptedException ex) { Exceptions.printStackTrace(ex); } catch (IOException ex) { Exceptions.printStackTrace(ex); } } }
public Boolean call() throws Exception { NativeProcessBuilder npb = NativeProcessBuilder.newProcessBuilder(execEnv); npb.setExecutable(collectCMD).setArguments("-n", "-r races", executable); // NOI18N Process p = npb.call(); List<String> out = ProcessUtils.readProcessOutput(p); int result = p.waitFor(); if (result == 0) { String identifier = loc("THA_InstrumentedIdentifier"); // NOI18N for (String s : out) { if (s.contains(identifier)) { return true; } } } return false; } });
@Override public void run() { try { errors.addAll(ProcessUtils.readProcessError(startedProcess)); } catch (Throwable ex) { } } });
private static String getCommandOutput(String path, String command, String flags, boolean bothStreams) { String res = commandCache.get(command+" "+flags); // NOI18N if (res != null) { //System.err.println("Get command output from cache #"+command); // NOI18N return res; } ArrayList<String> args = new ArrayList<String>(); StringTokenizer st = new StringTokenizer(flags," "); // NOI18N while(st.hasMoreTokens()) { args.add(st.nextToken()); } if (path == null) { path = ""; // NOI18N } ExitStatus status = ProcessUtils.executeInDir(path, ExecutionEnvironmentFactory.getLocal(), command, args.toArray(new String[args.size()])); StringBuilder buf = new StringBuilder(); //if (status.isOK()){ if (status.output != null) { buf.append(status.output); } buf.append('\n'); if (bothStreams) { if (status.error != null) { buf.append(status.error); } } commandCache.put(command+" "+flags, buf.toString()); // NOI18N return buf.toString(); } }
startError = ProcessUtils.readProcessErrorLine(engineProc); } catch (IOException ex) {
public CollectVersion call() throws Exception { NativeProcessBuilder npb = NativeProcessBuilder.newProcessBuilder(execEnv); npb.setExecutable(binDir + "version").setArguments(collectCMD); // NOI18N NativeProcess np = npb.call(); List<String> output = ProcessUtils.readProcessOutput(np); int result = np.waitFor(); if (result == 0) { return CollectVersion.getCollectVersion(output.get(0)); } return CollectVersion.UNKNOWN; } });
public boolean fileIsDirectory(File file) { //TODO: till API review if (executionEnvironment.isLocal()) { return file.isDirectory(); } else { return ProcessUtils.execute(executionEnvironment, "test", "-d", "\"" + file.getPath() + "\"").isOK(); //NOI18N } }
List<String> processOutput = null; try { processError = ProcessUtils.readProcessError(engineProc); processOutput = ProcessUtils.readProcessOutput(engineProc); } catch (IOException ex) { Exceptions.printStackTrace(ex);
private void run() { if (tool.getExecutionEnvironment().isLocal()) { // we're dealing with a local toolchain path = LinkSupport.resolveWindowsLink(path); File file = new File(path); if (!file.exists()) { alreadyRun = true; return; } } NativeProcessBuilder npb = NativeProcessBuilder.newProcessBuilder(tool.getExecutionEnvironment()); npb.setExecutable(path); npb.setArguments(getVersionFlags()); npb.redirectError(); try { NativeProcess p = npb.call(); p.getOutputStream().close(); final List<String> processOutput = ProcessUtils.readProcessOutput(p); if (processOutput != null && processOutput.size() > 0) { version = processOutput.get(0); } } catch (Exception ex) { // silently drop } alreadyRun = true; }
String res = ProcessUtils.readProcessOutputLine(process);
public boolean fileIsFile(File file) { //TODO: till API review if (executionEnvironment.isLocal()) { return file.isFile(); } else { return ProcessUtils.execute(executionEnvironment, "test", "-f", "\"" + file.getPath() + "\"").isOK(); //NOI18N } }
private void run() { if (tool.getExecutionEnvironment().isLocal()) { // we're dealing with a local toolchain path = LinkSupport.resolveWindowsLink(path); File file = new File(path); if (!file.exists()) { alreadyRun = true; return; } } NativeProcessBuilder npb = NativeProcessBuilder.newProcessBuilder(tool.getExecutionEnvironment()); npb.setExecutable(path); npb.setArguments(getVersionFlags()); npb.redirectError(); try { NativeProcess p = npb.call(); p.getOutputStream().close(); final List<String> processOutput = ProcessUtils.readProcessOutput(p); if (processOutput != null && processOutput.size() > 0) { version = processOutput.get(0); } } catch (Exception ex) { // silently drop } alreadyRun = true; }
public boolean fileCanRead(File file) { //TODO: till API review if (executionEnvironment.isLocal()) { return file.canRead(); } else { return ProcessUtils.execute(executionEnvironment, "test", "-r" ,"\"" + file.getPath() + "\"").isOK(); //NOI18N } }
@Override public PsData getData(boolean allProcesses) { PsData res = super.getData(allProcesses); // pargs call if needed if (res != null && !DISABLE_PARGS && !res.processes.isEmpty()) { NativeProcessBuilder pargsBuilder = NativeProcessBuilder.newProcessBuilder(exEnv); pargsBuilder.setExecutable("/usr/bin/pargs").redirectError(); // NOI18N pargsBuilder.getEnvironment().put("LC_ALL", "C"); // NOI18N String[] pargs_args = new String[res.processes.size()+1]; pargs_args[0] = "-Fl"; // NOI18N int idx = 1; for (Vector<String> proc : res.processes) { pargs_args[idx++] = proc.get(pidColumnIndex()); } pargsBuilder.setArguments(pargs_args); try { List<String> pargsOutput = ProcessUtils.readProcessOutput(pargsBuilder.call()); updatePargsData(res, pargs_args, pargsOutput); } catch (IOException ex) { Exceptions.printStackTrace(ex); } } return res; } }
public File[] listFiles(File file) { //TODO: till API review if (executionEnvironment.isLocal()) { return file.listFiles(); } else { final ExitStatus res = ProcessUtils.execute(executionEnvironment, "ls", "-A1"); //NOI18N if (res.isOK()) { String files = res.output; if (files != null) { BufferedReader bufferedReader = new BufferedReader(new StringReader(files)); String line; ArrayList<File> lines = new ArrayList<File>(); try { while ((line = bufferedReader.readLine()) != null) { lines.add(new File(line)); } bufferedReader.close(); } catch (IOException ex) { //hardly can happen during reading string Exceptions.printStackTrace(ex); return null; } return lines.toArray(new File[lines.size()]); } } } return null; }
for (String line : ProcessUtils.readProcessOutput(process)) { if (Log.Ps.debug) System.out.printf("PsOutput: '%s'\n", line); // NOI18N
private void setExecutionFlags(FileObject fob) { if (fob != null && fob.isValid()) { ExecutionEnvironment env = FileSystemProvider.getExecutionEnvironment(fob); String path = CndFileUtils.normalizePath(fob); ProcessUtils.execute(env, "/bin/chmod", "755", path); // NOI18N } } }
public void interrupt(final int pid) throws IOException { CndUtils.assertNonUiThread(); // use DebugBreakProcess on windows if (exEnv.isLocal() && Utilities.isWindows()) { File f = InstalledFileLocator.getDefault().locate("bin/GdbKillProc.exe", "org.netbeans.modules.cnd.debugger.common2", false); // NOI18N if (f.exists()) { ProcessUtils.execute(exEnv, f.getAbsolutePath(), "-s", "INT", Long.toString(pid)); //NOI18N } } else { try { CommonTasksSupport.sendSignal(exEnv, pid, Signal.SIGINT, null).get(); } catch (InterruptedException ex) { } catch (ExecutionException ex) { } } }