2012-08-22 47 views
0

的SH文件看起來如下上午CMD不起作用

#!/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中直接鍵入它,就像在亞行shell提示符,輸入am start -a android.intent.action.MAIN -n com.android.settings/.Settings,它的工作原理和運行活動

那麼,有什麼問題?

+0

呃試過在你的腳本上設置'chmod + x'嗎? –

+0

順便說一句,Android版本是2.3,並使用sh hello.sh來運行腳本。 – user1616565

+0

使用chmod 777 hello.sh,謝謝。 – user1616565

回答

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 
+0

謝謝,我試過你的方式,它的工作原理。 – user1616565

+0

但在我的情況下,我adb推a.sh到我的設備。然後chmod並運行。它仍然沒有工作。你可能會嘗試並破解原因。 – user1616565

+0

,在這種情況下,您不能通過./a.sh運行腳本,而是使用sh a.sh代替,並且我不知道爲什麼。無論如何。 – user1616565