public void execute(string[] cmmand, string directory, int type) { NetInfo netInfo = null; string sTmp = null; var builder = new ProcessBuilder(cmmand); if (directory != null) { builder.Directory(new File(directory)); } builder.RedirectErrorStream(true); var process = builder.Start(); var s = new Scanner(process.InputStream); s.UseDelimiter("\n"); while (s.HasNextLine) { sTmp = s.NextLine(); netInfo = parseDataNew(Java.Lang.String.(sTmp)); if (netInfo != null) { netInfo.type = type; saveToMap(netInfo); } } }
public virtual void RunCharniak(int n, string infile, string outfile, string errfile) { try { if (n == 1) { n++; } // Charniak does not output score if n = 1? IList <string> args = new List <string>(); args.Add(parserExecutable); args.Add(infile); ProcessBuilder process = new ProcessBuilder(args); process.Directory(new File(this.dir)); PrintWriter @out = IOUtils.GetPrintWriter(outfile); PrintWriter err = IOUtils.GetPrintWriter(errfile); SystemUtils.Run(process, @out, err); @out.Close(); err.Close(); } catch (IOException ex) { throw new Exception(ex); } }
private int ExecProcess(IList<string> cmds, FFMpegCallbacks sc) { //ensure that the arguments are in the correct Locale format // TODO: Useless since SOX is called internally. Remove. for ( int i = 0; i < cmds.Count; i++) { cmds[i] = string.Format(System.Globalization.CultureInfo.GetCultureInfo("en-US"), "%s", cmds[i]); } ProcessBuilder pb = new ProcessBuilder(cmds); pb.Directory(fileBinDir); var cmdlog = new Java.Lang.StringBuilder(); foreach (string cmd in cmds) { cmdlog.Append(cmd); cmdlog.Append(' '); } sc.ShellOut(cmdlog.ToString()); pb.RedirectErrorStream(true); var process = pb.Start(); StreamGobbler errorGobbler = new StreamGobbler(this, process.ErrorStream, "ERROR", sc); StreamGobbler outputGobbler = new StreamGobbler(this, process.InputStream, "OUTPUT", sc); errorGobbler.Run(); outputGobbler.Run(); int exitVal = process.WaitFor(); while (outputGobbler.IsAlive || errorGobbler.IsAlive); sc.ProcessComplete(exitVal); return exitVal; }