我有winform c#visual studio和一个在linux上运行的服务器。 我想执行这个命令" netstat -an | grep:80 | wc -l"来自我的winform界面 但我没有输出,我也不知道问题出在哪里。
这是我试过的
using System.Diagnostics;
using System.Security;
ProcessStartInfo proc_start_info = new ProcessStartInfo();
proc_start_info.FileName = "bash";
proc_start_info.Arguments = "-c netstat -an | grep :80 |wc -l ";
// -c allows to wait the command to be execute and exit
proc_start_info.RedirectStandardOutput = true;
proc_start_info.UseShellExecute = false;
proc_start_info.CreateNoWindow = true;
Process proc = new Process();
proc.StartInfo = proc_start_info;
proc.Start();
string result = proc.StandardOutput.ReadToEnd();
details_socket.Text = result;