-
Scripts for repetitive terminal commands like - reboot recovery
In Linux scripts are great for automating a series of terminal commands. Back in MS-DOS days I used batch files to automate a series of commands.
In Android you can also create scripts to automate a series of task - no typing just click to select - and it runs.
My MID7015 is rooted with a Superuser.apk. I'm using gscript app to run the script.
Here are the three steps I want to automate:
cp /sdcard/clockworkmod/recovery.img /sdcard/recovery.img
flash_image recovery /sdcard/recovery.img
reboot recovery
This simple script reboots my Coby to the Clockworkmod menu. No holding buttons required.
I try to keep root of /sdcard/ nearly empty and store files safely in subdirectories like /sdcard/clockworkmod (which is where the backups will be stored too.) So the first command is just to copy my Clockworkmod recovery.img file to the root of /sdcard/.
The second command flashes the image, the third command reboots the system.
So more of the nitty gritty. gscript has a text editor which I didn't like at all so I edited using TextEdit.
Install the app gscript
Launch TextEdit and type in the three commands above.
Save the file as /sdcard/gscript/Boot_Recovery.sh
(has to end with .sh or it will not run)
Launch gscript
Click on the menu button, select "Add Script"
click on [Load file]
Select the Boot_Recovery.sh file
Leave [x] Needs SU? turned on
click on [Save]
Now see how easy it is to boot to recovery.img
Just click on the script.
On my tablet a SuperUser screen pops up requiring my permission to run the script as superuser.
I click OK - you can set it to remember so this does not pop up again.
In seconds my tablet is booting the recovery image and I can select "backup" "restore" etc.
Sorry to be long winded but new bees need detail. It seems hard the first time but you'll appreciate it the second time you just click and reboot.
What other scripts have you created? Need to see?
Last edited by Ridgeland; 05-08-2011 at 05:40 AM.
Reason: Simpler version
-
01-29-2011 05:59 PM
# ADS
Circuit advertisement
-
If clockwork recovery is flashed correctly you would not need a script to flash it every time you want to boot into recovery. There are several reboot apps on the market that allow 2 click reboots, either into recovery or normal.
Sent from my SPH-M900
-
This thread was meant to help others see how to write and use scripts.
The example of recovery.img was meant only as an example.
If I had used an example with just "ls" that might have been too simple but would have still presented the concept.
Next I'll toy with scripts that install a list of apps (to use after a factory reset).
-
Ok. I got ya. I had a hard time getting clockwork to stick until I found the "mv" command. When I saw this I was thinking that some people may think this is a workaround for getting clockwork to stick, which would be a bad idea since you would not be able to access recovery if you were to get stuck in a boot loop or otherwise brick your tablet...
-
Senior Member
Achievements:
Funny... I was just thinking about batch files for Linux today...
Thanks for the tutorial, keep it coming.
What app are developers using to create Apps?
-
willber,
I had you in mind when I wrote this because you said you were using multiple backups and installs to test with and without Market.
Rebooting Recovery.img will be easy this way.
Don't you have Android Developers SDK?
What is Android? | Android Developers
Haven't you written your first helloworld.apk yet?
Are you a Linux user?
-
Senior Member
Achievements:
Yes the multiple rebootings and the old DOS days started me thinking about the batch ways of yesteryear. The need to reboot regarding the Market and the sleep issue is mute now. SoftLocker has resolved that issue.
I tried loading up SDK and did get past the path issue when using Win7 64 bit but the issued showed up again because my Packages To Install was empty...! So I put it aside.
Well I just fired up SDK again and low and behold, the Package list is now there. I guess Windoz just needed a cold boot...!
I'm new to Linux but have experience using low level and higher level programming languages so this is intriguing to me.
I'll investigate the SDK as I assume it is what's being used for writing apps.
I don't want to high jack your thread... maybe another thread could be started on the beginnings of app development. There might be enough people interested on this subject. Maybe move it out of this forum.
-
There's a development subforum over in the tcc8902 section.
Sent from my MID7015 using Tapatalk
-

Originally Posted by
willber
There might be enough people interested on this subject. Maybe move it out of this forum.
App development sounds fantastic. I'm game. 
Sent from my MID7015
-
So a script to load an app looks easy but is not.
From adb just run:
adb install /path/my.app.apk
Looks easy. Try that in the terminal
install /path/my.app.apk
and you get file not found, not the apk but the "install"
From xda-developers (I end up there a lot)
adb install in terminal emulator? - Page 2 - xda-developers
post #13 has a good script that works in this case.
The script though launches the installer which runs through the display of permissions and clicks required etc. Not good for a long list of apps.
So using a script for this doesn't look promising.
Another note is that I see a sh script is nothing more than a text file. I'm used to bash scripts (Bourne again Shell) which begin with #!/bin/bash. The sh scripts do not need a header line, just a simple text file like the old batch files in MS-DOS 3. I didn't test to see if the .sh is critical like the .bat was.