Perl “如何写入命令的输出”;adb push file.txt/sdcard/”文件;到文本文件?

Perl “如何写入命令的输出”;adb push file.txt/sdcard/”文件;到文本文件?,perl,command-line,batch-file,adb,Perl,Command Line,Batch File,Adb,命令: adb push test.mp4 /sdcard/test.mp4 命令的输出: 2717 KB/s (17104177 bytes in 6.146s) 我想把上面的输出写在一个文本文件中 我尝试了以下命令: adb push test.mp4 /sdcard/test.mp4 > Result.txt 但Result.txt文件仍然为空 如果你有任何想法,请帮忙 如果解决方案是使用perl或python,那么对我来说也没问题。假设您使用的是bash,您可以重定向stde

命令:

adb push test.mp4 /sdcard/test.mp4
命令的输出:

2717 KB/s (17104177 bytes in 6.146s)
我想把上面的输出写在一个文本文件中

我尝试了以下命令:

adb push test.mp4 /sdcard/test.mp4 > Result.txt
但Result.txt文件仍然为空

如果你有任何想法,请帮忙


如果解决方案是使用perl或python,那么对我来说也没问题。

假设您使用的是bash,您可以重定向
stderr

adb push test.mp4 /sdcard/test.mp4 2> Result.txt
adb push test.mp4 /sdcard/test.mp4 > Result.txt 2>&1
或者同时使用
stdout
stderr

adb push test.mp4 /sdcard/test.mp4 2> Result.txt
adb push test.mp4 /sdcard/test.mp4 > Result.txt 2>&1

请尝试adb shell,然后按test.mp4/sdcard/test.mp4>Result.txt亲爱的Keale,“adb shell”中没有“push”命令。在行尾添加2>&1,查看是否在Result.txt文件中获得文本。谢谢,在行尾添加“2>&1”对我有效。谢谢,此命令“adb push test.mp4/sdcard/test.mp4>Result.txt 2>&1”对我来说是完美的。