在亚行的shell传输二进制数据(即快速文件传输使用tar) [英] Transferring binary data over ADB shell (ie fast file transfer using tar)
问题描述
我一直想从我的Android设备将文件移动到我使用了类似于OSX机器:亚行外壳焦油-c directory_to_copy |焦油-x
。如此看来,远程焦油工作,但地方在途中该文件被破坏。
经过一番玩弄我发现:
I've been trying to move files from my android device to my osx machine using something similar to: adb shell tar -c directory_to_copy | tar -x
. It seems that the remote tar is working but somewhere on the way the file gets corrupted.
After some playing around I've found:
-
这似乎在亚行的shell命令转换LF到CRLF:
It seems the adb shell command translates LF to CRLF:
% adb shell 'cd /mnt/sdcard;echo hi>a.bin'
% adb shell 'cd /mnt/sdcard;cat a.bin' | hexdump -C
00000000 68 69 0d 0a |hi..|
00000004
% adb pull /mnt/sdcard/a.bin
0 KB/s (3 bytes in 0.457s)
% hexdump -C a.bin
00000000 68 69 0a |hi.|
00000003
看起来服务器或守护进程正在造成的,而不是客户端(见的len = 4):
It looks either the server or the daemon are causing that and not the client (see the len=4):
% ADB_TRACE=1 adb shell 'cd /mnt/sdcard;cat a.bin'
[... snip ...]
system/core/adb/commandline.c::read_and_dump():read_and_dump(): post adb_read(fd=3): len=4
[... snip ...]
我猜想,守护进程做这种翻译的shell命令的Windows用户。
I would guess that the daemon is doing that sort of translation in the shell command for windows users.
我的问题是:
- 在跆拳道? (那有什么和目的是什么?)
- 有没有办法告诉它(adbd?)不这样做呢?
- 在任何人都可以想到的任何有创意的方式来规避(我想到base64编码的数据,但我会preFER避免开销。此外,在创建本地文件是不是一种选择,因为我的文件系统是相当充分)
谢谢!
推荐答案
亚行是不是故意这样做的,但它不是足够聪明,从分配的终端克制当你给它一个命令来运行;对android端的终端是什么是烹调的字节数。而不是
Adb isn't doing this on purpose, but it's not smart enough to refrain from allocating a terminal when you give it a command to run; the terminal on the android side is what's cooking the bytes. Instead of
adb shell 'cd /mnt/sdcard;cat a.bin' | hexdump -C
尝试做
adb shell 'stty raw; cd /mnt/sdcard;cat a.bin' | hexdump -C
这指示终端设备没有裂伤的字节,而是通过他们通过。
This instructs the terminal device not to mangle the bytes at all, but to pass them through.
这篇关于在亚行的shell传输二进制数据(即快速文件传输使用tar)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!