android - bash 传递参数无效(adb)

标签 android linux bash shell adb

抱歉我的英语不好。 我编写了 bash 文件,它使用变量: shared_var=/system/xbin

我的脚本文件:

exec="./adb shell chmod 644 $shared_var/$2"
echo $exec
$exec

让我们运行这个脚本:

>bash gapp.sh misc su
./adb shell chmod 644 /system/xbin/su
: No such file or directory n/su

让我们在没有脚本的情况下运行字符串“./adb shell chmod 644/system/xbin/su”:

> ./adb shell chmod 644 /system/xbin/su
(No output, OK)

我有几个问题:

  1. 为什么脚本和终端直接输入结果不同?
  2. 为什么 adb 返回“No such file or directoryn/su”而不是“No such file or directory/system/xbin/su”(adb 结果看起来失真)
  3. 如何解决我的问题?

最佳答案

如果你的 shell 脚本只有,它是否有效

echo ./adb shell chmod 644 $shared_var/$2
./adb shell chmod 644 $shared_var/$2

即,不将其分配给另一个变量,并且没有带引号的字符串

此外,如果您在 Windows 中编辑文件,请确保使用 Unix 换行符保存文件。

关于android - bash 传递参数无效(adb),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10989119/

相关文章:

android - 无法在 Android Oreo 上将通知优先级设置为低

android - 如何在 Android 中使用接口(interface)名称执行 ping 命令(例如 : wlan0)?

c++ - 如何让 forkpty/execvp() 正确处理重定向和其他 bash-isms?

bash - 如何找到最大的元素并将其存储在数组中

android - 有没有办法在android的 native 代码中获取手机的数据连接状态?

Android:InflateException:二进制 XML 文件行:膨胀类 <unknown> 时出错

android -/proc/net/route 列的含义是什么?特别是 Flags 列

c - 为什么从 Linux 模块读取可以逐字符读取,但不能读取整个字符串

linux - 如何在 linux 中比较两个 latex 文件?

linux - 如何在 bash 脚本中读取文件时删除 1 个或多个匹配行