[英]Run Command From Within C# Mono Application in Linux
I am wondering if a Mono C# application running in Ubuntu can somehow run a terminal command. 我想知道在Ubuntu中运行的Mono C#应用程序是否能以某种方式运行终端命令。 For example, could the user give the program his or her password and then have the application run
例如,用户是否可以向程序提供他或她的密码,然后运行应用程序
sudo apt-get install application-name
(console requests password)
password
(console requests confirmation)
y
Preferably, this would be done without actually opening a terminal visible to the user, so that the application could provide the necessary feedback and manage the whole operation cleanly with as little user interaction as possible. 优选地,这将在不实际打开用户可见的终端的情况下完成,使得应用程序可以提供必要的反馈并且在尽可能少的用户交互的情况下干净地管理整个操作。
Is there a way to do that? 有没有办法做到这一点? If so, how?
如果是这样,怎么样? Let me know if clarification is needed.
如果需要澄清,请告诉我。 Thank you!
谢谢!
应该可以,您只需将密码重定向到Process类的StandardInput流。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.