Shell脚本不会在Android上运行,但会在Ubuntu上运行

时间:2011-08-05 06:09:47

标签: android unix shell

编写此脚本是为了对rooted设备上的build.prop文件进行更改。它将在ubuntu上运行,但在设备上运行时会抛出以下错误。 6:语法错误:期待“in”

LINE_BREAK=""
while read line
do
    case $line in
        ro.ril.reject.cs.ss.enabled?=*)
            line="ro.ril.reject.cs.ss.enabled=1";;
        ro.ril.reject.mo.ussd.enabled?=*)
            line="ro.ril.reject.mo.ussd.enabled=1";;
        ro.phone.function?=*)
            line="ro.phone.function=0";;
        ro.bt.profiles?=*)
            line="ro.bt.profiles=4270339";;
        service.brcm.bt.ag_supported?=*)
            line="service.brcm.bt.ag_supported=0";;
    esac
    NEW_FILE="$NEW_FILE$LINE_BREAK$line"
    LINE_BREAK="\n"
done </system/build.prop
echo $NEW_FILE>/system/build.prop

在android中编写脚本是否有细微差别?提前谢谢!

2 个答案:

答案 0 :(得分:0)

我没有Android,但我会尝试在$ line附近加上引号:

case "$line" in

只是预感。对于那个很抱歉。也许你已经尝试过了。

答案 1 :(得分:0)

您可以尝试使用SL4A编写脚本,SL4A是android的脚本层。 参考 http://android.amolgupta.in/2011/04/scripting-on-android.html

相关问题