抱歉我的英语不好。
我编写了 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)
我有几个问题:
- 为什么脚本和终端直接输入结果不同?
- 为什么 adb 返回“No such file or directoryn/su”而不是“No such file or directory/system/xbin/su”(adb 结果看起来失真)
- 如何解决我的问题?
最佳答案
如果你的 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/