Scripts for repetitive terminal commands like - reboot recovery

Discussion in 'Coby Generation 1 Technical' started by Ridgeland, Jan 29, 2011.

  1. Ridgeland

    Ridgeland Member

    Joined:
    Dec 14, 2010
    Messages:
    285
    Likes Received:
    9
    Trophy Points:
    87
    Location:
    Ridgeland, WI, USA
    Tablet / Device:
    Coby MID7015-4G
    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:
    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: May 8, 2011
    • Like Like x 2
  2. jetta02awp

    jetta02awp Member

    Joined:
    Dec 14, 2010
    Messages:
    49
    Likes Received:
    1
    Trophy Points:
    72
    Location:
    NULL
    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
     
  3. Ridgeland

    Ridgeland Member

    Joined:
    Dec 14, 2010
    Messages:
    285
    Likes Received:
    9
    Trophy Points:
    87
    Location:
    Ridgeland, WI, USA
    Tablet / Device:
    Coby MID7015-4G
    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).
     
  4. jetta02awp

    jetta02awp Member

    Joined:
    Dec 14, 2010
    Messages:
    49
    Likes Received:
    1
    Trophy Points:
    72
    Location:
    NULL
    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...
     
  5. willber

    willber Member

    Joined:
    Jan 9, 2011
    Messages:
    147
    Likes Received:
    1
    Trophy Points:
    87
    Location:
    Mississauga Canada
    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?
     
  6. Ridgeland

    Ridgeland Member

    Joined:
    Dec 14, 2010
    Messages:
    285
    Likes Received:
    9
    Trophy Points:
    87
    Location:
    Ridgeland, WI, USA
    Tablet / Device:
    Coby MID7015-4G
    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?
     
  7. willber

    willber Member

    Joined:
    Jan 9, 2011
    Messages:
    147
    Likes Received:
    1
    Trophy Points:
    87
    Location:
    Mississauga Canada
    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.
     
  8. l_n

    l_n Senior Member

    Joined:
    Dec 28, 2010
    Messages:
    788
    Likes Received:
    99
    Trophy Points:
    102
    Location:
    TN, USA
    Tablet / Device:
    Mid7015
    There's a development subforum over in the tcc8902 section.

    Sent from my MID7015 using Tapatalk
     
  9. BKenney

    BKenney Member

    Joined:
    Dec 10, 2010
    Messages:
    138
    Likes Received:
    5
    Trophy Points:
    87
    Location:
    Florida
    Tablet / Device:
    Coby Kyros MID7015
    App development sounds fantastic. I'm game. :)



    Sent from my MID7015
     
  10. Ridgeland

    Ridgeland Member

    Joined:
    Dec 14, 2010
    Messages:
    285
    Likes Received:
    9
    Trophy Points:
    87
    Location:
    Ridgeland, WI, USA
    Tablet / Device:
    Coby MID7015-4G
    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.
     
  11. Ridgeland

    Ridgeland Member

    Joined:
    Dec 14, 2010
    Messages:
    285
    Likes Received:
    9
    Trophy Points:
    87
    Location:
    Ridgeland, WI, USA
    Tablet / Device:
    Coby MID7015-4G
    For Linux fans here is a bash script to use adb to install all the apps in a directory.
    For example if you have backed up all the keeper apps and reinstall update.zip this script will reinstall all those keeper apps for you.
     
  12. Ridgeland

    Ridgeland Member

    Joined:
    Dec 14, 2010
    Messages:
    285
    Likes Received:
    9
    Trophy Points:
    87
    Location:
    Ridgeland, WI, USA
    Tablet / Device:
    Coby MID7015-4G
    Script for grey to move eBooks from /nand/ to /sdcard/
    in Gscript: [x] Needs SU?
    cp copies the eBooks which are directories not just files.
    rm removed the eBooks from /nand/
     
  13. Ridgeland

    Ridgeland Member

    Joined:
    Dec 14, 2010
    Messages:
    285
    Likes Received:
    9
    Trophy Points:
    87
    Location:
    Ridgeland, WI, USA
    Tablet / Device:
    Coby MID7015-4G
    Script to edit lcd_density
    This is a script I use in a Linux Terminal to edit lcd_density. What it does:
    Make a backup of the original build.prop on the Coby
    Copy build.prop to PC's /tmp/
    Ask the user to choose 240, 220, 200, 180 or 160 (defaults to 200)
    Edit PC's /tmp/build.prop per user's choice
    Copy edited build.prop back to the Coby.
    Reboot the Coby so the change takes effect.
     
  14. Ridgeland

    Ridgeland Member

    Joined:
    Dec 14, 2010
    Messages:
    285
    Likes Received:
    9
    Trophy Points:
    87
    Location:
    Ridgeland, WI, USA
    Tablet / Device:
    Coby MID7015-4G
    Script to edit heapsize
    I wrote a script to edit lcd_density. It was a trival change to clone it for heapsize changes.
    What it does:
    Make a backup of the original build.prop on the Coby
    Copy build.prop to PC's /tmp/
    Ask the user to choose 16, 24, 32, 40 or 48 (Defaults to 24)
    Edit PC's /tmp/build.prop per user's choice
    Copy edited build.prop back to the Coby.
    Reboot the Coby so the change takes effect.
     
  15. Ridgeland

    Ridgeland Member

    Joined:
    Dec 14, 2010
    Messages:
    285
    Likes Received:
    9
    Trophy Points:
    87
    Location:
    Ridgeland, WI, USA
    Tablet / Device:
    Coby MID7015-4G
    Backup/Restore AngryBirds high scores

    The obvious problem with trying all these ROMs and/or starting over with a fresh install of the Coby ROM is that I've had to start over all the levels of AngryBirds a few times. Some levels took me like 30 tries (i.e. 3-2).

    The fix is to save/restore two files from:
    /data/data/com.rovio.angrybirds/files/
    You'll need a rooted tablet to copy from and to /data/data/

    In the new ROM you have to first create a highscores.lua by completing the first level 1-1. Then the restore script will work.

    First is the script to backup your current high score. Just read it and you'll see what it does and how.
    Run it with gscript with su power.

    Both of these scripts assume you have three Angry Birds versions:
    Angry Birds, Angry Birds - Seasons, Angry Birds - Rio
    If you have more or less you'll need to edit the script for your use.

    Copy and paste this to /sdcard/gscript/Games_Save_Scores.sh
    The second script copies in a previous high score. Remember to first complete level 1-1 and then close AngryBirds.

    Copy and paste this to /sdcard/gscript/Games_Restore_Scores.sh
    Note the last section is to change the owner of the files. If owner is not correct when AngryBirds tries to write a new score the app crashes. On my tablet my script also backs up Jewels. A little experimenting and you can see what to back up for other games.
     
    Last edited: May 2, 2011

Share This Page

Search tags for this page
add to build prop script terminal emulator
,
android script commands for reboot in recovery
,

android terminal commands

,

Android Terminal Commands List

,

android terminal save command

,
batch chown on android terminal emulator
,
coby terminal reboot
,

easy reboot recovery script

,
ebooks on android terminal commands
,
how to change lcd density with terminal emulator
,

how to make terminal emulater batch file

,
reboot recovery script android
,
reboter script terminal emulator
,

script for android terminal emulator recovery boot

,
script reboot pour android
,
scripter commands reboot recovery
,
scripts to automate terminal emulator xda
,
terminal editor to fix coby tablet
,
terminal emulator batches
,
what can i do from terminal emulator and scripter