我需要使用C#代码执行以下操作:
- 在后台打开putty.exe(类似于cmd窗口)
- 使用远程主机的IP地址登录
- 输入用户名和密码
- 依次执行多个命令。
- 运行另一个命令,获取响应告诉我之前运行的命令已成功执行
所以我尝试像这样做:
ProcessStartInfo proc = new ProcessStartInfo()
{
FileName = @"C:\putty.exe",
UseShellExecute = true, //I think I need to use shell execute ?
RedirectStandardInput = false,
RedirectStandardOutput = false,
Arguments = string.Format("-ssh {0}@{1} 22 -pw {2}", userName, hostIP, password)
... //How do I send commands to be executed here ?
};
Process.Start(proc);