我正在使用 Ruby Net:SSH lib 与远程 PC 建立 ssh 连接,然后执行远程 cmd。当我开始我的 SSH 连接时,我没有问题,但有时,不是在任何地方,当我使用 exec 时!我有一个错误返回到 stderr,它是“tput:$TERM 没有值并且没有指定 -T”。
代码示例:
Net::SSH.start(nodeAddress, nodeLogin, :password => nodePassword, :port => nodePort) do |ssh|
ssh.exec! "cat \"#{sftpSshKey}\"" do |channel, stream, data|
if(stream == :stderr)
return "error tput"
end
end
end
如果有人有想法或已经有这个问题。
cat 的示例工作正常,如果我使用它,我会收到“tput”错误:
ssh.exec! "test -r \"#{sftpSourceFile}\" && echo \"Read\" || echo \"NRead\"" do |channel, stream, data|
如果我使用它,我没有错误:
ssh.exec! "test -w \"#{nodeDestinationPath}\" && echo \"Write\" || echo \"NWrite\"" do |channel, stream, data|
问候。