이 코드를 사용하면 로그인 창이 암호를 묻는 메시지가 나타나지만 암호를 셸 창에 쓸 수없는 것 같습니다.C# cygwin scp를 실행하고 Process 및 StandardInputWriter를 사용하여 암호를 입력하는 방법은 무엇입니까?
Process scp = new Process();
scp.StartInfo.FileName = @"c:\cygwin\bin\scp";
scp.StartInfo.Arguments = "/cygdrive/c" + path + " " + username + "@" + ServerName + ":/cygdrive/c/Temp/.";
scp.StartInfo.UseShellExecute = false;
scp.StartInfo.RedirectStandardOutput = true;
scp.StartInfo.RedirectStandardError = true;
scp.StartInfo.RedirectStandardInput = true;
scp.Start();
//I've tried this with no success:
using (StreamWriter sw = scp.StandardInput)
{
if (sw.BaseStream.CanWrite)
{
sw.WriteLine(pass);
}
}
// Another failed attempt:
scp.StandardInput.Write(pass + Environment.NewLine);
scp.StandardInput.Flush();
Thread.Sleep(1000);
나는 이것이 cygwin과 함께 작동하도록 할 수 있지만 오히려 C#을 사용하여 Windows 입/출력과 상호 작용할 수 있음을 알고 있습니다.