How to fetch a binary file from a remote embeded system using telnet?

六月ゝ 毕业季﹏ 提交于 2019-12-11 11:17:20

问题


I have a remote embedded system and it is telnet-able. How can I fetch a binary file from it using ruby? If it were a text file, I could have used:

  con = Net::Telnet::new("Host"=>ip,"Timeout"=>200)  #Host not host
  File.open("fetched_file","w+") do |f|
        con.cmd("cat /ect/file")  {|data| f.write(data)}
  end

But this wouldn't work for binary file you won't get desirable data by cating it.


回答1:


establish your telnet connection then
send the command:

uuencode filename -

to the remote host, replacing filename with the filename

take the data you are sent and pass it to uudecode on your system




回答2:


If the device has uuencode installed, you could use that to 'wrap' the binary into printable characters. Other possibility is to run dd if=/etc/file 2>/dev/null to dump the data (however I am not completely certain this will word any better...)



来源:https://stackoverflow.com/questions/2062834/how-to-fetch-a-binary-file-from-a-remote-embeded-system-using-telnet

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!