Frage
Frage

Reputation: 13

tput: No value for $TERM and no -T specified while using Ruby Net:SSH

I'm using the Ruby Net:SSH lib to do a ssh connection to a remote PC and then execute a remote cmd. When I start my SSH connection I have no issue but sometimes, not everywhere, when I use the exec! I have an error returned into the stderr which is "tput: No value for $TERM and no -T specified".

Example of code :

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

If someone have an idea or already had this problem.

The example with the cat works fine, if I use this I got the "tput" error :

ssh.exec! "test -r \"#{sftpSourceFile}\" && echo \"Read\" || echo \"NRead\"" do |channel, stream, data|

If I use this I don't have the error:

ssh.exec! "test -w \"#{nodeDestinationPath}\" && echo \"Write\" || echo \"NWrite\"" do |channel, stream, data|

Regards.

Upvotes: 1

Views: 160

Answers (1)

Wayne Conrad
Wayne Conrad

Reputation: 107959

This example from the Net::SSH source code shows how to use a channel to execute an interactive command, and then both read the command's output, and provide input to the command.

      #   ssh.open_channel do |channel|
      #     channel.exec("/invoke/some/command") do |ch, success|
      #       abort "could not execute command" unless success
      #
      #       channel.on_data do |ch, data|
      #         puts "got stdout: #{data}"
      #         channel.send_data "something for stdin\n"
      #       end
      #
      #       channel.on_extended_data do |ch, type, data|
      #         puts "got stderr: #{data}"
      #       end
      #
      #       channel.on_close do |ch|
      #         puts "channel is closing!"
      #       end
      #     end
      #   end
      #
      #   ssh.loop

Upvotes: 0

Related Questions