开发者

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

开发者 https://www.devze.com 2022-12-16 21:28 出处:网络
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:

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("fetche开发者_如何学Pythond_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.


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


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...)

0

精彩评论

暂无评论...
验证码 换一张
取 消