private void WriteStandardInput() { StandardInput.Write(Options.StandardInput); if (Options.AutoCloseStandardInput) { StandardInput.Close(); } }
private int InternalRun(TextReader input, string[] arguments) { InternalStart(arguments); if (input != null) { char[] buffer = new char[1024]; int count; while (0 != (count = input.Read(buffer, 0, buffer.Length))) { StandardInput.Write(buffer, 0, count); } } WaitForExit(); return(ExitCode); }
public bool Run() { Start(); StandardInput.Write("chcp 437" + Environment.NewLine); StandardInput.Write("ping 8.8.8.8 -n 1" + Environment.NewLine); StandardInput.Close(); String output = StandardOutput.ReadToEnd(); WaitForExit(); Close(); //var a = from line in output.Split('\n') // where line.IndexOf("Reply from 8.8.8.8: ") != -1 // let c = line.Replace("Reply from 8.8.8.8: ","").Split(' ') var list = output.Split('\n').Where(c => { return(c.IndexOf("Reply from 8.8.8.8: ") != -1); }).Select(c => { return(c.Replace("Reply from 8.8.8.8: ", "").Replace("\r", "").Split(' ')); }).FirstOrDefault(); if (list != null) { var dic = list.Select(t => { return(t.Split('=')); }).Select(m => { return(new { k = m[0], v = m[1] }); }).ToDictionary(i => i.k, v => v.v); if (dic.ContainsKey("time")) { return(true); } } return(false); }
public void SendCommand(string command) { StandardInput.Write(command); StandardInput.Flush(); }