[英]Send prompt input to Diagnostics.Process
I'm currently solving a problem of starting external tool from .net app. 我目前正在解决从.net应用启动外部工具的问题。 I have this part of code:
我有这部分代码:
proc.StartInfo = new ProcessStartInfo(_app, _args);
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
But, after starting application I get an error to StandartError output witn promt confirmation answer "enter y/n". 但是,启动应用程序后,我收到StandartError输出错误并提示确认输入“是/否”。 I've already tried to input "y" via standart input, right after starting process, but still get the same error.
我已经尝试在启动过程之后立即通过标准输入输入“ y”,但是仍然会遇到相同的错误。
var standartInput = proc.StandardInput;
standartInput.AutoFlush = true;
standartInput.WriteLine("y");
standartInput.Close();
I'd really appreciate any help. 我真的很感谢您的帮助。 Thanks.
谢谢。
PS: PuTTY Secure Copy client - is the external app I'm using from code. PS:PuTTY Secure Copy客户端-是我从代码中使用的外部应用程序。 There is a confirmation promt, when running app for first time to save servers fingerprint in system registry.
首次运行应用程序时,有一个确认提示将服务器指纹保存在系统注册表中。
The code looks OK to me. 该代码在我看来还可以。 Maybe you need to sleep for a second or something before writing the "y".
在写“ y”之前,您可能需要睡一秒钟左右。 I would imagine that the program takes a little while to ask the user for input
我可以想象该程序需要一些时间来询问用户输入
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.