0

I have created a script which first checks the android version and then installs the corresponding files to the system (as files are not same for every android version)

Here is the script

#!/system/bin/sh

VER=$(echo $(getprop ro.build.version.release))
LIB=/system/lib/libncurses.so
XBINS=/system/xbin/sqlite3
XBINO=/system/xbin/openvpm
XBINZ=/system/xbin/zipalign
LIBD=/system/lib
XBIND=/system/xbin

mount -o rw,remount /system

case $VER in

"2.3"*)
cp tmp/binbox/2.3.*/lib/libncurses.so "$LIBD"
cp tmp/binbox/2.3.*/xbin/sqlite3 "$XBIND"
cp tmp/binbox/2.3.*/xbin/openvpm "$XBIND"
cp tmp/binbox/2.3.*/xbin/zipalign "$XBIND"
chmod 644 "$LIB"
chown 0.0 "$LIB"
chmod 6755 "$XBINS"
chown 0.0 "$XBINS"
chmod 6755 "$XBINO"
chown 0.0 "$XBINO"
chmod 6755 "$XBINZ"
chown 0.0 "$XBINZ"
;;
"4.0"*)
cp /tmp/binbox/4.0.*/lib/libncurses.so "$LIBD"
cp /tmp/binbox/4.0.*/xbin/sqlite3 "$XBIND"
cp tmp/binbox/4.0.*/xbin/openvpm "$XBIND"
cp tmp/binbox/4.0.*/xbin/zipalign "$XBIND"
chmod 644 "$LIB"
chown 0.0 "$LIB"
chmod 6755 "$XBINS"
chown 0.0 "$XBINS"
chmod 6755 "$XBINO"
chown 0.0 "$XBINO"
chmod 6755 "$XBINZ"
chown 0.0 "$XBINZ"
;;
"4.1"*)
cp /tmp/binbox/4.1.*/lib/libncurses.so "$LIBD"
cp /tmp/binbox/4.1.*/xbin/sqlite3 "$XBIND"
chmod 644 "$LIB"
chown 0.0 "$LIB"
chmod 6755 "$XBIN"
chown 0.0 "$XBIN"
;;
"4.2"*)
cp /tmp/binbox/4.2.*/lib/libncurses.so "$LIBD"
cp /tmp/binbox/4.2.*/xbin/sqlite3 "$XBIND"
chmod 644 "$LIB"
chown 0.0 "$LIB"
chmod 6755 "$XBIN"
chown 0.0 "$XBIN"
;;
"4.3"*)
cp /tmp/binbox/4.3.*/lib/libncurses.so "$LIBD"
cp /tmp/binbox/4.3.*/xbin/sqlite3 "$XBIND"
chmod 644 "$LIB"
chown 0.0 "$LIB"
chmod 6755 "$XBIN"
chown 0.0 "$XBIN"
;;
"4.4"*)
cp /tmp/binbox/4.4.*/lib/libncurses.so "$LIBD
cp /tmp/binbox/4.4.*/xbin/sqlite3 "$XBIND"
chmod 644 "$LIB"
chown 0.0 "$LIB"
chmod 6755 "$XBIN"
chown 0.0 "$XBIN" 
;;
esac

Running the script I get a getprop:not found This script is ran in cwm recovery and files are placed in tmp as the script is ran in recovery i dont get the exact result of the script but log is as shown below

Installing: /external_sd/a.zip
Finding update package...
I:Update location: /external_sd/a.zip
Opening update package...
Installing update...
minzip: Extracted file "/tmp/2.3/Arjun2.3.txt"
minzip: Extracted file "/tmp/4.0/Arjun4.0.txt"
minzip: Extracted file "/tmp/4.1/Arjun4.1.txt"
minzip: Extracted file "/tmp/4.2/Arjun4.2.txt"
minzip: Extracted file "/tmp/4.3/Arjun4.3.txt"
minzip: Extracted file "/tmp/4.4/Arjun4.4.txt"
minzip: Extracted file "/tmp/binbox.sh"
about to run program [/sbin/busybox] with 5 args
about to run program [/sbin/busybox] with 5 args
about to run program [/sbin/mount] with 2 args

Mounting /system 

about to run program [/tmp/binbox.sh] with 2 args

about to run program [/sbin/busybox] with 3 args
Unmounting partitions...

script result was [Installation is complete...]
Installation is complete... 

Install from sdcard complete.

here binbox.sh is the script hope that someone can find a solution

1 Answers1

0

Given that your system is having trouble with adb shell, and based on our debugging in the comments, the best solution for you seems to be the std unix solution, like

VER=$(awk -F= '/ro\.build\.version\.release/{print $NF}' /system/build.prop) 
echo "VER=$VER"
VER=4.1.2

original solution left for others facing the same issue.

It's clear that the line

VER=$(echo $(getprop ro.build.version.release))

is creating the error message.

Per several posting here on S.O. and googling, it looks like you need to use

VER=$(echo $(adb shell getprop ro.build.version.release))

If that doesn't work, then the more general solution is to do some digging and find out where getprop is, AND then either add the full path to the name, like

/usr/local/special/bin/getprop

OR add that path to the PATH env variable

PATH="/usr/local/special/bin:$PATH"

at the top of this script, OR in one of the shell's .rc (.profile, .bashrc, etc, etc). files.

IHTH

Community
  • 1
  • 1
shellter
  • 36,525
  • 7
  • 83
  • 90
  • well i have tried adding adb shell in between and got adb:not found and for more information getprop is a command which gives the available information from build.prop file of android system which is located in /system/build.prop – Arjun Purushothaman Mar 22 '14 at 14:24
  • ok, so maybe `VER=$(grep ro.build.version.release/system/build.prop)` solves your problem? Good luck. – shellter Mar 22 '14 at 14:39
  • adding VER=$(grep ro.build.version.release/system/build.prop) showed no errors in running but it failed to copy the files from tmp to their folders So the script does nothing now ! any idea about that ? – Arjun Purushothaman Mar 23 '14 at 11:58
  • Isee I had a typo there, did you spot it and correct? Missing space char. Try `VER=$(grep ro.build.version.release /system/build.prop)` AND, I realize now, this would return the whole line, so try `VER=$( awk '/ro.build.version.release/{sub(/^.*=/,"",$0);print $0)}' /system/build.prop)` . This assumes there is an `equals (=)` sign between the key and value. If this doesn't work, please edit your question to include the results of `awk '/ro.build.version.release/{print}' /system/build.prop` . Good luck. – shellter Mar 23 '14 at 12:06
  • yes,, i had spotD that... first tried with a space and then without also,,,but no progress – Arjun Purushothaman Mar 23 '14 at 12:13
  • And you get a blank line from `awk '/ro.build.version.release/{print}' /system/build.prop` ? Hm... try `awk '/ro\.build\.version\.release/{print}' /system/build.prop` If you still get no output, (and no error messages?) then you have to look inside /system/build.prop with an editor and see if there are special formatting that your search will need to work-around. Unfortunately, I don't have the environment that you are using to test with, so I'm about out of ideas at this point. Let me know if you get any error messages, or edit your Q with chunk from `build.prop`. Good luck. – shellter Mar 23 '14 at 12:20
  • ro.build.version.release=4.1.2 this is how the value is set in build.prop file and i suppose awk works as a busybox command EDIT = got an error as "unexpected token " – Arjun Purushothaman Mar 23 '14 at 12:28
  • And you want VER=4.1.2, right? So now try just `awk -F= '/ro.build.version.release/{print $NF}' /system/build.prop` and if that returns just 4.1.2 (which in my test just now, it worked), then `VER=$(awk ...)` ; echo "VER=$VER"` to check that it is working. Good luck. – shellter Mar 23 '14 at 12:35
  • ok i will try that now,,, as you know this script is running in recovery only thing that i can get is recovery log that only says the script has completed/ error > i cannot get the log of whole process..EDIT flashed this time and no errors in the log but all i can say that files has not copied yet . – Arjun Purushothaman Mar 23 '14 at 12:46
  • I've been focused completely on your posted error message. I would have assumed that you'd try to make sure things fixed before running thw whole body of the script. Add `set -vx` near the top of the script. This output will show you each block of code that it is going to execute (as it is in the script file), and then lines preceded with `+` signs to indicate the actual line that is being executed, with values substituted for variables. Alternatively, I would edit the block for 4.1 and add `echo ` for each line that you expect to be executed. Then you'll see if there are any further probs. GL – shellter Mar 23 '14 at 12:52
  • but the problem is that log says the script is executed and no more xtra details about it, and if any errors then it says there is an error in the line .As i have said before , this is run in recovery i cannot get the exact logs what makes the problem,, here is the log Installing: /external_sd/a.zip minzip: Extracted file "/tmp/4.1/Arjun4.1.txt" minzip: Extracted file "/tmp/4.2/Arjun4.2.txt" minzip: Extracted file "/tmp/4.3/Arjun4.3.txt" minzip: Extracted file "/tmp/binbox.sh" about to run program [/tmp/binbox.sh] with 2 args script result was[Installation is complete] Installation is complete – Arjun Purushothaman Mar 24 '14 at 07:40
  • I don't understand. Please edit your question to include this information and use the `{}` tool at the top left of the edit box so this information will appear formatted correctly. Good luck. – shellter Mar 24 '14 at 11:28
  • This answer doesn't seem to make much sense at all; by all appearances the distinction between what runs *on the device* and what runs *on a machine connected to the device by ADB* is being ignored. My reading of the question is that the script will execute *on the device*, hence no usage of adb, no reference to /usr, etc. – Chris Stratton Mar 24 '14 at 18:30
  • the 'run' information for the question was just added. Maybe you can take over solving the O.P.s problem. I've had enough. – shellter Mar 24 '14 at 18:59
  • guys the problem is solved the script works flawless, i messed up with the /system mounting and now its fixed ,thanks for shellter and chris for the help,,,,,,thanq guys ,expecially shellter – Arjun Purushothaman Mar 25 '14 at 10:58