[英]C# command line execute commands belongs to another executable
下面是我尝试使用参数运行一个命令的代码。 (调用Tectia SFTP客户端配置文件并上传文件)
Process cmd = new Process();
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.Arguments = $"/c sftpg3 {profile}";
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.UseShellExecute = false;
cmd.Start();
using (StreamWriter sw = cmd.StandardInput){
if (sw.BaseStream.CanWrite)
sw.WriteLine($"/c sput {filename} {output}");
}
该过程开始后,它登录到SFTP中并被卡住。 它不会输入下一个命令,因为它被视为另一个程序。
想问一下登录后如何执行下一个命令? 我尝试了通过&&串联调用CMD,但也无法正常工作。 我们只能根据客户要求通过命令行使用SFTP。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.