无法运行在bash脚本命令ADB [英] Can't run adb commands in bash script

查看:753
本文介绍了无法运行在bash脚本命令ADB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从亚行的shell推出A​​ndroid绑定设置。这样做的主要目的是通过运行一个shell脚本来启用USB绑定模式。我用下面一组在我的Ubuntu终端(12.04)的命令:

 亚行外壳
我开始-n com.android.settings / .TetherSettings
睡眠7
输入抽头162 159
输入抽头385 607

在执行上述命令逐个这种方法工作得很好,但我不能够运行它们正常的shell脚本。请帮忙!
下面是完整的脚本:

 #!/ bin / sh的
亚行的shell
我开始-n com.android.settings / .TetherSettings
睡眠7
输入抽头162 159
输入抽头385 607

我想,它无法找到在我的系统,以亚行的路径。我试过的实际路径在SDK目录ADB工具取代了第一道防线。这也不起作用。任何工作都围绕这个?
(很抱歉,如果这个问题似乎很傻。我真的很新bash脚本编程!)

编辑:更新后的脚本: -

 #!/ bin / sh的
CD /家庭/ evinish /文档/ Android的/ ADT-束Linux的x86_64-20130219 / SDK /平台的工具
亚行壳
我开始-n com.android.settings / .TetherSettings
睡眠7
输入抽头162 159
输入抽头385 607


解决方案

谢谢大家!我终于解决了这个问题。以下是更新后的脚本:

 #!/ bin / sh的
CD /家庭/ evinish /文档/ Android的/ ADT-束Linux的x86_64-20130219 / SDK /平台的工具
./adb设备
./adb壳
我开始-n com.android.settings / .TetherSettings
睡眠15
输入抽头162 159
输入抽头385 607

睡眠10

唯一的问题是亚行前失踪./。

I'm trying to launch Android tethering settings from adb shell. The main purpose of doing so is to enable USB tethering mode by running a shell script. I'm using the following set of commands on my Ubuntu Terminal (12.04):

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

This method works fine when the commands are executed one by one, but I'm not able to run them as normal shell script. Please help! Here is the complete script:

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

I guess, it can't find the path to adb in my system. I've tried replacing the first line with the actual path to adb tool in SDK directory. That didn't work either. Any work around for this? (Sorry if the question seems silly. I'm really new to bash scripting!)

EDIT: Updated script:-

#!/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
"

解决方案

Thanks everybody! I finally solved the problem. Here is the updated script:

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

The only problem was missing "./" before adb.

这篇关于无法运行在bash脚本命令ADB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆