0

sh 文件如下所示

#!/system/bin/sh
am start -a android.intent.action.MAIN -n com.android.settings/.Settings
echo hello,world
exit 1

但它报告错误

Starting: Intent { act=android.intent.action.MAIN cmp=com.android.settings/.Sett
}gs
Error type 3
} does not exist.lass {com.android.settings/com.android.settings.Settings
hello,world
exit: Illegal number: 1

但是当我直接在 sh shell 中输入它时,比如在 adb shell 提示符中,输入am start -a android.intent.action.MAIN -n com.android.settings/.Settings,它可以工作,并运行 activty

所以有什么问题?

4

1 回答 1

0

我刚试过你的脚本,它显然有效。也用过 2.3.3

echo "#!/system/bin/sh" >a.sh
#echo "#!/system/bin/sh" >a.sh
#cat a.sh
#!/system/bin/sh
# echo "am start -a android.intent.action.MAIN -n com.android.settings/.Settings" >>a.sh
echo "am start -a android.intent.action.MAIN -n com.android.settings/.Settings" >>a.sh
# cat a.sh
cat a.sh
#!/system/bin/sh
am start -a android.intent.action.MAIN -n com.android.settings/.Settings
# echo "echo hello, world" >>a.sh
echo "echo hello, world" >>a.sh
# echo "exit 0" >>a.sh
echo "exit 0" >>a.sh
# cat a.sh
cat a.sh
#!/system/bin/sh
am start -a android.intent.action.MAIN -n com.android.settings/.Settings
echo hello, world
exit 0   
# chmod 755 a.sh
chmod 755 a.sh
# ./a.sh
./a.sh
Starting: Intent { act=android.intent.action.MAIN cmp=com.android.settings/.Settings }
hello, world  
# cat /proc/cpuinfo
cat /proc/cpuinfo
Processor       : ARM926EJ-S rev 5 (v5l)
BogoMIPS        : 287.53
Features        : swp half thumb fastmult vfp edsp java
CPU implementer : 0x41
CPU architecture: 5TEJ
CPU variant     : 0x0
CPU part        : 0x926
CPU revision    : 5

Hardware        : Goldfish
于 2012-08-22T13:31:02.570 回答