samba禁用时拷贝服务器文件到本地的脚本

Android系统开发一般在ubuntu服务器上,我们办公电脑一般是windows。在将编译出来的模块push到板子上时,一般采用adb push 方式。

有时由于种种原因会出现服务器禁用了samba,导致无法直接用adb push 的情况。

下面介绍用winscp 走ssh 拷贝服务器生成模块到本地电脑后,再push到机器上的方式。

以fwk为例,bat脚本如下:

bash 复制代码
@echo on

setlocal

:: 设置SFTP服务器的相关信息
set HOST=XXXXXXX
set USER=XXX
set PASSWORD=XXXXXXXXXXX
set REMOTE_DIR=XXXXXXXXXXXXX/system/framework
set LOCAL_DIR=%CD%

:: 删除之前的缓存的文件夹,并重新创建
RMDIR framework /S /Q
mkdir framework

:: 创建WinSCP脚本
echo open sftp://%USER%:%PASSWORD%@%HOST% > winscp_script.txt
echo lcd %LOCAL_DIR% >> winscp_script.txt
:: 我们这里只拷贝framework相关文件;若是apk等模块,不需要进入文件夹,直接用get . 代替即可。
echo lcd framework >> winscp_script.txt
echo cd %REMOTE_DIR% >> winscp_script.txt
echo get framework.jar >> winscp_script.txt
echo get services.jar >> winscp_script.txt
echo get services.jar.prof >> winscp_script.txt
echo get framework-res.apk >> winscp_script.txt
echo get oat >> winscp_script.txt
echo get arm >> winscp_script.txt
echo exit >> winscp_script.txt

:: 使用WinSCP执行脚本,这会将服务器文件拷贝到本地电脑
"C:\Program Files (x86)\WinSCP\winscp.com" /script=winscp_script.txt

:: 删除临时脚本文件
del winscp_script.txt


endlocal

::下面直接在本地push
adb wait-for-device

adb  root
adb  remount
adb  shell     mount -o rw,remount,rw /system
adb  shell    mount -o rw,remount,rw /product  
adb  push    framework  /system



adb shell sync
adb shell    ls -al /system/framework/framework.jar
adb shell    ls -al /system/framework/services.jar
adb shell    ls -al /system/lib/libssljni.so

@pause

adb reboot
相关推荐
移动开发者1号1 分钟前
剖析 Systrace:定位 UI 线程阻塞的终极指南
android·kotlin
移动开发者1号1 分钟前
深入解析内存抖动:定位与修复实战(Kotlin版)
android·kotlin
whysqwhw2 分钟前
OkHttp深度架构缺陷分析与革命性演进方案
android
Digitally2 小时前
如何将文件从 iPhone 传输到 Android(新指南)
android·ios·iphone
whysqwhw3 小时前
OkHttp深度架构缺陷分析与演进规划
android
用户7093722538513 小时前
Android14 SystemUI NotificationShadeWindowView 加载显示过程
android
木叶丸4 小时前
跨平台方案该如何选择?
android·前端·ios
顾林海4 小时前
Android ClassLoader加载机制详解
android·面试·源码
用户2018792831674 小时前
🎨 童话:Android画布王国的奇妙冒险
android
whysqwhw5 小时前
OkHttp框架的全面深入架构分析
android