如何使用 telnet 从远程嵌入式系统获取二进制文件?
我有一个远程嵌入式系统,它可以远程登录。如何使用 ruby 从中获取二进制文件?如果它是一个文本文件,我可以使用:
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
但这不适用于二进制文件,您将无法通过 cat
获得所需的数据。
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 cat
ing it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
然后建立您的 telnet 连接
发送命令:
到远程主机,将 filename 替换为 filename
获取发送的数据并将其传递到系统上的
uudecode
establish your telnet connection then
send the command:
to the remote host, replacing filename with the filename
take the data you are sent and pass it to
uudecode
on your system如果设备安装了
uuencode
,您可以使用它将二进制文件“包装”为可打印字符。另一种可能性是运行 dd if=/etc/file 2>/dev/null 来转储数据(但是我不完全确定这会更好......)If the device has
uuencode
installed, you could use that to 'wrap' the binary into printable characters. Other possibility is to rundd if=/etc/file 2>/dev/null
to dump the data (however I am not completely certain this will word any better...)