adb一键push文件到QNX

由于ftpput每次只能传输单个文件,不支持文件夹传输,所以用tar打包处理。

@REM #########################################################################
@REM # File Name: adb_pushfileto_qnx.bat
@REM # Author: Panda Young
@REM # Version: 1.1.02
@REM # Created Time: 2023年08月08日 星期二 17时47分20秒
@REM #########################################################################
@echo off
setlocal enabledelayedexpansion
color 02

for /f %%i in ('adb shell "getprop dev.bootcomplete"') do set BOOTSTATUS=%%i
if NOT "%BOOTSTATUS%" == "1" (
    color 04
    echo Android device is not ready!
    pause
    color 07
    exit /b
)

adb root
adb remount
adb shell "mount -o rw,remount /"

set qnx_host_ip=192.168.1.1
set qnx_target_path=/sound_a/
set android_tmp_path=/data/local/tmp/
set tar_path=tar.exe
set BUSYBOX_PATH=busybox

goto :get_input
:check_busybox
for /f %%i in ('adb shell "find / -name busybox" 2^>nul') do set BUSYBOX_PATH=%%i
if "%BUSYBOX_PATH%" == "" (
    color 04
    echo Not found busybox in the device!
    pause
    color 07
    exit /b
)

:get_input
set /p put_file=Enter the file path to be pushed: 
if NOT exist %put_file% (
    color 04
    echo Not found the file or directory! Please check the path.
    pause
    color 07
    exit /b
)

for %%I in (%put_file%) do (
    set target_file_name=%%~nxI
    set win_path=%%~dpI
)

if exist "%put_file%\.\" (
    set IS_DIR=1
    set file_suffix=.tar.gz
    set archive_file_name=%target_file_name%!file_suffix!
    %tar_path% -zcvf %win_path%!archive_file_name! -C %win_path% %target_file_name%
    set target_file_name=!archive_file_name!
    adb push %win_path%!target_file_name! %android_tmp_path%
) else (
    adb push %put_file% %android_tmp_path%
)
if errorlevel 1 (
    color 04
    echo Push file to Android device failed!
    pause
    color 07
    exit /b
) else (
    echo Push file to Android device successfully!
)

adb shell "%BUSYBOX_PATH% ftpput -u root %qnx_host_ip% %qnx_target_path%%target_file_name% %android_tmp_path%%target_file_name%"
if errorlevel 1 (
    color 04
    echo Push file to QNX device failed!
    pause
) else (
    if !IS_DIR!==1 (
        echo Push file to QNX device successfully! You can use 'tar -xvf' unpack the file.
    ) else (
        echo Push file to QNX device successfully!
    )
)

adb shell "rm %android_tmp_path%%target_file_name%"
if errorlevel 1 (
    color 04
    echo Delete the temporary file failed!
    pause
    color 07
    exit /b
) else (
    echo Delete temporary file in Android successfully!
)

if !IS_DIR!==1 (
    del /Q /S /F %win_path%!target_file_name!
    if errorlevel 1 (
        color 04
        echo Delete the temporary file failed!
        pause
        color 07
        exit /b
    ) else (
        echo Delete temporary file in the host successfully!
    )
)

color 07
exit /b

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值