如何在ubuntu中使用c#编写子进程stdin?
我绝对不擅长制作软件,尤其是c#,但有一次我需要一些小的。我不得不执行一些终端命令,我面临着如何在ubuntu中使用c#编写子进程stdin?,c#,ubuntu,C#,Ubuntu,我绝对不擅长制作软件,尤其是c#,但有一次我需要一些小的。我不得不执行一些终端命令,我面临着sudo问题 proc = new System.Diagnostics.Process (); proc.StartInfo.FileName = "/bin/bash"; proc.StartInfo.Arguments = "-c \" " + "sudo service apache2 restart" + " \""; proc.StartInfo
sudo
问题
proc = new System.Diagnostics.Process ();
proc.StartInfo.FileName = "/bin/bash";
proc.StartInfo.Arguments = "-c \" " + "sudo service apache2 restart" + " \"";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start ();
正如你所知,在命令sudo之后,我必须输入密码,但我想自动输入。也许我可以在我不知道的时候写。
或者我可以使用sudoidunno限制该命令。请帮助我在windows的ubuntu中安装dotnet core 检查官方文件
在windows的ubuntu中安装dotnet core 检查官方文件
您可以查看以下示例:
它是为Windows编写的,但与您希望获得的行为完全相同。您可以查看以下示例:
它是为Windows编写的,但它与您希望获得的行为完全相同。问题到底是什么,因为您似乎不知道自己真正想要什么…?我想执行sudo service apache2 restart命令,但它不起作用。很明显,因为密码是必需的,但我不能键入与c#程序工作时相同的密码。问题到底是什么,因为您似乎不知道自己真正想要什么…?我想执行命令sudo service apache2 restart,但它不起作用。显然,因为密码是必需的,但我不能键入与c#程序工作相同的密码。