Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#SSH文本,数字发送?_C#_.net_Ssh - Fatal编程技术网

C#SSH文本,数字发送?

C#SSH文本,数字发送?,c#,.net,ssh,C#,.net,Ssh,当脚本运行时,希望我输入数字,卡在命令2上,“SshCommand sc3”未运行命令3 脚本运行时,您希望运行多长时间?她问道。他要我输入数字 但是我没能把电话号码发出去,电话号码不在那一行 using (var client = new SshClient(host, user, pass)) { client.Connect(); SshCommand sc1 = client.CreateCommand("chmod +x xxx.sh"

当脚本运行时,希望我输入数字,卡在命令2上,“SshCommand sc3”未运行命令3

脚本运行时,您希望运行多长时间?她问道。他要我输入数字 但是我没能把电话号码发出去,电话号码不在那一行

   using (var client = new SshClient(host, user, pass))
    {
    client.Connect();
    SshCommand sc1 = client.CreateCommand("chmod +x xxx.sh");
    SshCommand sc2 = client.CreateCommand("./xxx.sh");
    SshCommand sc3 = client.CreateCommand("echo 500");
    SshCommand sc4 = client.CreateCommand("500");
    client.Disconnect();
    }

我对您的流程的理解是您
chmod
启动一个脚本,向它传递一些输入,然后等待它完成。如果我正确地理解了你的问题陈述,你最好使用。这样,您的互动性就变成了一种练习,或是一个命令和一个特定的响应:

/*
#我在另一端使用了以下脚本来模拟活动:
#!/bin/bash
echo“输入睡眠时间:”
阅读时间睡眠
睡眠$timeToSleep
回声“我们完成了”
*/
使用(var客户端=新的SshClient(主机、用户、过程))
{
client.Connect();
var shell=client.CreateShellStream(“bash”,80,50,1024,1024);//我认为shell名称对于正确解析控件字符序列至关重要
Expect(new ExpectAction(“#”),()=>//我们在这里等待shell提示。如果您的shell不同,您可能需要调整正则表达式
{
shell.WriteLine(“chmod+x xxx.sh&./xxx.sh”);
}));
Expect(新的ExpectAction(“输入睡眠时间:”,()
壳牌公司(下称“5”);
}));
Expect(新的ExpectAction(“#”),scriptOutput=>{
Console.WriteLine(脚本输出);
}));
client.Disconnect();
}

由于您尚未共享您运行的实际脚本,因此我无法更具体地说明。希望这能让你走上充实细节的轨道。

理想情况下,我们至少有一个脚本(或要求输入的部分)能够准确地再现你的问题。我怎么做。谢谢例如:我正在设置它要求我输入数字500 chmod+x installer.sh./installer我需要打印数字500我爱你,它对我帮助很大,非常感谢:)