Errno::ENOTTY Inappropriate ioctl for device when trying to send file to SFTP
Asked Answered
K

1

7

I am using a rails webapp and trying to send an xml file to a sftp server, using the following script:

Net::SSH.start(SFTP_HOST, sftp_user, {:port => SFTP_PORT, :password => sftp_password}) do |ssh|
ssh.sftp.connect do |sftp|
  sftp.upload!( measurements_xml_file_path( meas ).to_s ) do |event, uploader, *args|
    case even
    when :open
      puts "Starting upload"

    when :finish
      puts "Finished upload"
      return true
    end
  end
end

Nevertheless, I am always get an error "Errno::ENOTTY ... Inappropriate ioctl for device". Any help how to fix this error?

Kurt answered 5/10, 2021 at 10:49 Comment(1)
I solved a more or less similar issue here: stackoverflow.com/questions/69796705Neoterize
P
1

An IOCTL is a Device Input and Output Control meaning the error comes from a poorly formed or misconfigured command being sent to the server.

It could be the PTY issue described in a comment as the server does not have a terminal output and SFTP is attempting to display the progress bar.

Alternatively, it could be a result of a poorly formed command being sent to the server as the output of measurements_xml_file_path( meas ).to_s is unknown and possibly incorrect. SFTP takes two arguments, one for the input file on the host and one for the output file on the server.

class Net::SFTP

To upload a single file to the remote server, simply specify both the local and remote paths:

uploader = sftp.upload("/path/to/local.txt", "/path/to/remote.txt")
Petro answered 8/5, 2023 at 20:40 Comment(1)
"message": "Inappropriate ioctl for device", "backtrace": [ "/web_head/shared/bundle/ruby/2.7.0/gems/net-ssh-5.2.0/lib/net/ssh/prompt.rb:45:in noecho'", "/web_head/shared/bundle/ruby/2.7.0/gems/net-ssh-5.2.0/lib/net/ssh/prompt.rb:45:in ask'", "/web_head/shared/bundle/ruby/2.7.0/gems/net-ssh-5.2.0/lib/net/ssh/authentication/methods/password.rb:68:in ask_password'", "/web_head/shared/bundle/ruby/2.7.0/gems/net-ssh-5.2.0/lib/net/ssh/authentication/methods/password.rb:21:in authenticate'", Received this error for wrong password.Figurine

© 2022 - 2024 — McMap. All rights reserved.