微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – 无法在bash脚本中运行adb命令

我正在尝试从adb shell启动Android网络共享设置.这样做的主要目的是通过运行shell脚本来启用USB网络共享模式.我在我的Ubuntu终端(12.04)上使用以下命令集:

adb shell
am start -n com.android.settings/.TetherSettings
sleep 7
input tap 162 159
input tap 385 607

当命令逐个执行时,此方法可以正常工作,但我无法将它们作为普通的shell脚本运行.请帮忙!
这是完整的脚本:

#!/bin/sh
adb shell
am start -n com.android.settings/.TetherSettings
sleep 7
input tap 162 159
input tap 385 607

我想,它无法在我的系统中找到adb的路径.我已经尝试用SDK目录中的adb工具的实际路径替换第一行.那也行不通.有什么解决方法吗?
(对不起,如果这个问题看起来很愚蠢.我真是个新手来编写脚本!)

编辑:更新的脚本: –

#!/bin/sh
cd /home/evinish/Documents/Android/adt-bundle-linux-x86_64-20130219/sdk/platform-tools
adb shell "
am start -n com.android.settings/.TetherSettings
sleep 7
input tap 162 159
input tap 385 607
"

解决方法:

adb shell会在您的Android设备上打开一个shell.后续命令在该shell的上下文中输入.在远程命令周围添加引号:

adb shell "
am start -n com.android.settings/.TetherSettings
sleep 7
input tap 162 159
input tap 385 607
"

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐