Shell scripts?!

0xicl33n

New member
Oct 23, 2011
2
0
0
Visit site
XDA was completly UNHELPFUL!!! NO responses, NOTHING! -_-

First post here, ive downloaded things previously but never posted, i need some help with a shell script...



I want a little "home launcher" that opens in my terminal that lets me select various things. i did some research and found that android uses MKSH(default shell of MirOS BSD, FreeWRT, MidnightBSD, Android-x86, Android 3.0 (Honeycomb) and possibly Android 4 (Ice Cream Sandwich). Its a derivation of the korn shell. So i used the source of a korn shell menu, and entered my android commands, it didnt work. I know theyre different shell types and therefore have slightly different syntax, is there anyone who can help me make my script work?? Is there any other commands that can make my script echo the Android version? Kernel version?? Anything?! Also is there perhaps a command reference for MKSH for ANDROID. The regular MKSH dox' dont say anything about android..

Device is: rooted TF201 Transformer Prime w/ ICS 4.3 @ 1.6GHZ

The first batch of code is the modified source code, and the second script is a remake with only a few things removed, the second one is the one that id like, i would like the menu from the first one if possible, since neither of them work...


Code:
#!/bin/sh
# declare some vars:
btdir="sdcard/bt5"
# functions for menu:
func_1 () {
sh   /sdcard/bt5/bt
}
func_2 () {
su ; cd /sdcard
}
func_3 () {
su ; cd /
}
func_4 (){
 su ; sd /sdcard/downloads
 }
menu_list () {
clear
echo "######################################################################"
echo "#"
echo "#" "                     " "Welcome to QuikSkript"
echo "#"                       
echo "#""        ""A simple ""Home"" app,that can launch various things from trem!"
echo "#"
echo "#" "              ""BackTrack Is invoked from $btdir"
echo "#" "              ""Shell Is running from $SHELL $KSH_VERSION"
echo "#"
echo "#######################################################################"
echo
                echo "To Boot BackTrack press 1 \n"
                echo "To drop into a superuser shell @ /sdcard press 2 2 \n"
                echo "To go to mount point / , press 3"
                echo "To go to downloads, press 4"
                echo "To quit, press "q" \n"
}

go_ahead () {
tput smso
echo "Press any key to return to the menu  \c"
tput rmso
oldstty=`stty -g`
stty -icanon -echo min 1 time 0
dd bs=1 count=1 >/dev/null 2>&1
stty "$oldstty"
echo
}
func_select () {
tput smso
echo "\nPlease make your selection ( )\b\b\c"
read selection
tput rmso
case $selection in
     1) clear ; func_1 ; go_ahead ;; 
     2) clear ; func_2 ; go_ahead ;;
     3) clear ; func_3 ; go_ahead ;;
     4) clear ; func_4 ; go_ahead ;;
     q|Q) tput rmso ; clear ; exit 0 ;;
esac
}
#
# Here is where is gets looped - basically forever, until
# the "q" option is selected, causing an explicit exit
#

while `true`
do
menu_list
func_select
done


Redone script:



Code:
runbt="sh /sdcard/bt5/bt"
btdir="/sdcard/bt5"
ch2homefolder="cd /sdcard"
ch2systemroot="cd /"
downloads=" cd /sdcard/download"
func_1 () {
cd /sdcard
}
func_2 () {
cd /
}
echo "Started on:" ; date
cat /proc/version
echo  "Running from $SHELL $KSH_VERSION"
grep 'Processor' /proc/cpuinfo 
grep 'MemTotal' /proc/meminfo 
grep 'MemFree' /proc/meminfo
grep 'PageTables' /proc/meminfo ;echo
echo  "---> BackTrack invoked from $btdir <---"
echo "Network interfaces:" ; echo ; ifconfig wlan0 ; echo 
echo  "##########################################################################"
echo  "#                                                                        #"
echo  "#                           Welcome to quikskript!                       #" 
echo  "#                                                                        #"
echo  "#  A simple sh "home" app, that can launch various things from the term!  #"
echo " ########################################################################  "
echo
echo
echo "Choose An option:"
echo
echo "1) Boot BackTrack"
echo
echo "2) Go to Home folder w/ SU" 
echo
echo "3) to the System Root, /"
echo
echo "4) Go to Downloads folder"
read option
case $option in
1) $runbt ;;
2) clear ; func_1 ;;
3) clear ; func_2 ;;
4) $downloads ;;
esac

this is a screenshot of the redone one..
25h05ec.png


other problems: only the first option works, and to boot backtrack it asks for superuser, which i try to give the shell on initial command but that didnt work, it wouldnt open the rest of the script, i tried everything from su && sh test.sh , su | test, and su ; test and su ;; test and su > test.sh and even su || test.sh

NONE OF THEM WORK!

HELP ME PLEEEASE ;____;
 

pazzo02

Well-known member
Feb 16, 2011
1,168
75
0
Visit site
Re: Shell scripts?!?!?!

To be sure, this is some pretty technical stuff you're doing. You'll need to have some patience waiting for someone with the know-how to come along. How long was you post on xda without any responses? That is the place I would expect you to have a better chance of getting help with this.
 

Forum statistics

Threads
943,150
Messages
6,917,533
Members
3,158,848
Latest member
kerokekerol