2017-05-18 39 views

回答

0

您需要添加依赖关系的System.Diagnostics.Process API Reference

则可以执行bash命令状这个。 请将此视为伪代码,因为我不在Linux机器附近进行测试

ProcessStartInfo psi = new ProcessStartInfo(); 
     psi.FileName = "/bin/bash"; 
     psi.Arguments = "-c sudo ifconfig eth0 192.168.0.1 netmask 255.255.255.0"; 
     psi.UseShellExecute = true; 
     psi.RedirectStandardOutput = true; 

     Process proc = new Process 
     { 
      StartInfo = psi 
     }; 

     proc.Start(); 
相关问题