我在通过 ssh 执行 python 脚本时遇到问题(使用 c# 和 SharpSSH)。
我有连接并且可以编写简单的命令,例如“startx”和“sudo shutdown ...”
当我尝试运行 python 脚本时,程序会冻结并且没有任何反应。我用“putty”尝试了完全相同的程序,它按预期工作。
python脚本运行,我得到数据(打印'无激光,快速移动:Dx =',stepx,'Dy =',stepy)whitch对我的应用程序很重要。
C# SharpSSH 连接
ssh = new SshStream(host, user, password);
//Set the end of response matcher character
ssh.Prompt = "#";
//Remove terminal emulation characters
ssh.RemoveTerminalEmulationCharacters = true;
//Reading from the SSH channel
string response = ssh.ReadResponse();
return response;
C# 启动 Gcode_executer.py 不起作用并冻结程序(在 pc 上)树莓派不运行 python 文件
try
{
ssh.Write("sudo python cnc/Gcode_executer.py"); // Write ssh to RPI
// works it in putty
if (ssh.CanRead == true)
{
return ssh.ReadResponse(); // return string from terminal from RPI
}
else
{
return "No response";
}
}
catch
{
return "Catch NO response";
}
我能做些什么来解决这个问题?