如何在adb shell上使用su命令? [英] How to use su command over adb shell?
问题描述
我需要制作一个脚本来在Android设备上执行很多事情,我的设备已经扎根,当我进入shell时,我可以给命令su,它可以工作,但是我需要像下面这样传递该命令: /p>
I need to make a script that executes a lots of thing on Android device, my device is rooted, when I enter on the shell, I can give the command su, and it works but I need pass this command like:
adb shell "
su;
mv /sdcard/Download/app_test /data/local;
cd /data/local;
./app_test;
exit;
exit;
"
当我在su起作用之前放置一些命令时,根据我读到的内容su创建了一个立即返回的新shell,但是我需要在su shell上给出命令,我该怎么做?
when I put some commands before the su it works, according what I read su creates a new shell that return immediately, but I need give commands on the su shell, how can I do that?
推荐答案
如果您的手机已扎根,则可以使用"su -c"命令运行命令.
Well if you phone is rooted you can run commands with the "su -c" command.
这是在build.prop文件上使用cat命令获取电话产品信息的示例.
Here is an example of a cat command on the build.prop file to get a phones product information.
adb shell"su -c'cat/system/build.prop | grep" product'"
这将调用root权限并在''
This invokes root permission and runs the command inside the ' '
请注意5个结束引号,这是关闭所有结束引号所必需的,否则会出现错误.
Notice the 5 end quotes, that is required that you close ALL your end quotes or you will get an error.
为澄清起见,格式如下.
For clarification the format is like this.
adb shell"su -c'[您的命令在此处]'"
确保以完全相同的方式输入命令,就像在shell中运行该命令一样.
Make sure you enter the command EXACTLY the way that you normally would when running it in shell.
尝试一下,希望对您有所帮助.
Give it a try, hope this helps.
这篇关于如何在adb shell上使用su命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!