• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

GScript * Easily launch/save shell scripts from within Android UI * - Useful scripts

Search This thread

rogro82

Retired Senior Recognized Developer
May 1, 2008
862
445
plus.google.com
As some of you might have seen or even used, I have created an application that allows executing of shell scripts from within Android and it will even allow you to create a direct shortcut on your homescreen to a script ( for example to start Debian or reboot your phone ).

I know a lot of developers ( I also didnt at first ) don't look in the "applications and games" section, but i thought it was the best place to post the actual application.

I will keep updating that post with the actual application process/updates, but ive created this thread to see if people ( I think most of the actual linux experienced people are in this section ) would like to share their linux knowledge to other peoples uploading useful .sh files ( for backing up stuff etc etc ), so that less experienced can just load them in to my application, without risking all typos.

So if you have a nice script that is useful please upload it so we can all benefit from it.

The actual application can be found here:
http://forum.xda-developers.com/showthread.php?t=486486

Please dont ask question or place suggestions about the application in this thread, but use the one Ive created for the actual development and keep this thread for scripts only.

Regards,

Rob
 
Last edited:

the.snks

Senior Member
Jan 26, 2009
97
3
I was thinking about starting a thread just like this one-- for everyone to post up their scripts. Don't know why I didn't. Anyway, I asked the question awhile back how to create a script for remounting the file system as read/write, which led to my discovery of GScript. In any case, here's what I was told to use:

mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system

Be advised that I have no idea if this actually works or not. Perhaps someone could test and post the results?
 
Last edited:

Gary13579

Retired Moderator
Nov 14, 2008
526
69
that takes to long, i find it easier when i am using the comp to just click my terminal(which is almost always up and running) and type reboot_phone(i have a script on the computer that contains the comand adb shell reboot) and also another for rebooting into recovery and one more for bootloader

i guess i'm lazy but if i can find a way to automate anything i do in life i go ahead and do it. i have a script for nearly everything i do to my phone.

on a more on-topic note, i was hoping someone would post the command to reboot and apply an update.zip, i know it is in the JF autoupdater, but i just want to be able to hit a shortcut on my home screen to apply themes as well.

Code:
su
echo "boot-recovery
--update_package=/sdcard/update.zip" > /cache/recovery/command
reboot recovery

Untested, you might have to play around with the /sdcard/update.zip to get it to load properly, I'm not sure exactly how you put the path in there. This will, for sure, reboot it into recovery mode, and tries to automatically apply an update.zip.

Edit:
--update_package=sdcard:update.zip

Should do it. I hope.
 

benmyers2941

Senior Member
Oct 26, 2007
368
8
Phoenix, AZ
Here's a script I built to make a rom into the "lite" version needed by many of the themes. It's not much but it's my first one.

Code:
mount -o rw,remount -t yaffs2, /dev/block/mtdblock /system
rm -r /system/media/audio/ringtones
rm -r /system/media/audio/notifications
reboot
 

benmyers2941

Senior Member
Oct 26, 2007
368
8
Phoenix, AZ
Code:
su
echo "boot-recovery
--update_package=/sdcard/update.zip" > /cache/recovery/command
reboot recovery

Untested, you might have to play around with the /sdcard/update.zip to get it to load properly, I'm not sure exactly how you put the path in there. This will, for sure, reboot it into recovery mode, and tries to automatically apply an update.zip.

Edit:
--update_package=sdcard:update.zip

Should do it. I hope.

You don't need the "su" at the beginning. Gscript has a checkbox to indicate if SU is needed and will add it on it's own. Putting it in causes the script to hang.
 

KyleK29

Senior Member
Oct 15, 2006
500
34
Anyway to make it close the script window when the script completes? Right now I have it doing an app backup and echoing DONE. But I'd like to automate the process if possible.

Exit doesn't seem to work.
 

wpbcubsfan

Senior Member
Jun 29, 2008
212
14
Chicago
Code:
su
echo "boot-recovery
--update_package=/sdcard/update.zip" > /cache/recovery/command
reboot recovery

Untested, you might have to play around with the /sdcard/update.zip to get it to load properly, I'm not sure exactly how you put the path in there. This will, for sure, reboot it into recovery mode, and tries to automatically apply an update.zip.

Edit:
--update_package=sdcard:update.zip

Should do it. I hope.

It does reboot into recovery mode but I get the error "Can't mount /sdcard/Update.zip Installation aborted."

I'm able to just apply the update by pressing Alt+S but would be nice if it was all automated.
 

beagz

Senior Member
Jan 11, 2009
1,187
23
Greenacres, FL
Got it!!!

ok!

used this as script to change theme

cp /sdcard/themes/aero/update.zip /sdcard/
echo "boot-recovery
--update_package=SDCARD:update.zip" > /cache/recovery/command
reboot recovery


Needed to use caps for SDCARD!!!

found it poking around the recovery.c file

better still no need to copy over update.zip in root Just in case of emergency.
Code:
echo "boot-recovery
--update_package=SDCARD:themes/aero/update.zip" > /cache/recovery/command
reboot recovery
 
Last edited:

wpbcubsfan

Senior Member
Jun 29, 2008
212
14
Chicago
ok!

used this as script to change theme

cp /sdcard/themes/aero/update.zip /sdcard/
echo "boot-recovery
--update_package=SDCARD:update.zip" > /cache/recovery/command
reboot recovery


Needed to use caps for SDCARD!!!

found it poking around the recovery.c file

better still no need to copy over update.zip in root Just in case of emergency.
Code:
echo "boot-recovery
--update_package=SDCARD:themes/aero/update.zip" > /cache/recovery/command
reboot recovery

Dude, you rock! Thanks!
 

indiekid97

Senior Member
Feb 28, 2009
61
0
Cocoa Beach, Florida
Clear Caches

I use this script to clear almost all of the app caches

Code:
#Deletes all caches in one fell swoop :]
#Locations of the caches were taken from various sites, including xda and androidcommunity.com
#written by indiekid97

#Deletes browser cache
rm -R /data/data/com.android.browser/cache/webviewCache


#Deletes Maps cache
rm -R /data/data/com.google.android.apps.maps/files


#Deletes StreetView
rm -R /data/data/com.google.android.street/cache

#Deletes Market cache
rm -R /data/data/com.android.vending/cache

#Deletes Tunewiki cache
rm -R /data/data/com.tunewiki.lyricplayer.android/cache/webviewCache

#Deletes Myspace cache
rm -R /data/data/com.myspace.android/files

#Deletes GMail cache
rm -R /data/data/com.google.android.gm/cache/webviewCache
 

a1t

Senior Member
Nov 9, 2008
130
3
Denver
Copy from /system/app

I get get the phone to copy from data app and private however, when I try to copy apps from /system/app it does nothing.

Mod_edit

any ideas?

I also tried to cd in the script to navigate to the data and still it only runs the first two copy commands.
 
Last edited by a moderator:

Mikey

Retired Senior Moderator
Oct 10, 2007
6,274
1,742
Wheaton, Il
LG V60 ThinQ
Google Pixel 6 Pro
removed copyright procedureYou can not display procedures concerning the two app folders being transferred to Fat32 portion of card.
I get get the phone to copy from data app and private however, when I try to copy apps from /system/app it does nothing.

Mod_edit

any ideas?

I also tried to cd in the script to navigate to the data and still it only runs the first two copy commands.
 

a1t

Senior Member
Nov 9, 2008
130
3
Denver
Woops

Sorry dudes. If we can still talk about any possibilities, I'm down. if not, oh well. now on eggshells

looking for script to move a specific directory on /system to a location on my sdcard

if anyone is interested PM me.
 
Last edited:

Proxin

Senior Member
Feb 6, 2009
471
14
Pallet Town
What would the script be to disable USB mounting to the computer? It's a hassle for me to have to un-plug the USB cable when I want to unmount, it would be very beneficial to have a quick press of an icon on the Home screen to do this :D

*Edit: after tinkering around with it for a bit, I see that this cannot be done- I tried mounting the SD card to computer and then running a script, *any* script will not load because GScript requires /sdcard/gscript_tmp.sh to be accessable in order to run a script.
Mounting to computer and then running a script from GScript simply shows an error:
Code:
Error:

/sdcard/gscript_tmp.sh
SO, in order for it to work, GScript would probably have to be configured to search for the script elsewhere to load while the SD card is mounted.
 
Last edited:

Proxin

Senior Member
Feb 6, 2009
471
14
Pallet Town
Here is a small script to back up current system sounds to the SD card, probably most useful if you do this prior to using the Make Lite script:

Code:
cp -r /system/media/audio /sdcard/audio

If there are any errors please let me know.
Once they're backed up, you can merge the folder into /sdcard/media for proper use with Ringdroid. :)
I'm not sure whether to use cp -r or cp -a, so I will stick with -r for now and see if anyone has any other suggestion.
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    Simple Script

    This is well below anything you guys have posted, but I thought since the site help me create it and GScript let me run it, I would post it. I use Script Scheduler found on this site to have it run once a day in the background.

    Code:
    busybox renice 5 `pidof com.google.process.gapps`
    busybox renice -18 `pidof com.android.phone`
    busybox renice -18 `pidof mediaserver`
    busybox renice -18 `pidof mediaserver`
    busybox renice -16 `pidof com.android.launcher`
    busybox renice -15 `pidof com.htc.music`
    busybox renice -15 `pidof com.android.music`
    {
    
    mv /sdcard/com.tokasiki.android.voicerecorder/*.3gp /sdcard/"Computer Data"/"Voice Recorder"/ ;
    
    mv /sdcard/DCIM/Camera/*.jpg /sdcard/"Computer Data"/Pictures/ ;
    
    mv /sdcard/DCIM/Camera/*.3gp /sdcard/"Computer Data"/Video/ ;
    
    cp /sdcard/download/* /sdcard/"Computer Data"/Downloads/ ;
    
    mv /sdcard/FxCamera/* /sdcard/"Computer Data"/Pictures/ ;
    
    mv /sdcard/iMusic/*.mp3 /sdcard/"Computer Data"/Music/ ;
    
    mv /sdcard/mp3/* /sdcard/"Computer Data"/Music/ ;
    
    mv /sdcard/"Music Junk"/* /sdcard/"Computer Data"/Music/ ;
    
    mv /sdcard/TubeDownloader/* /sdcard/"Computer Data"/Video/ ;
    
    mv /sdcard/Video/* /sdcard/"Computer Data"/Video/ ;
    }

    Its a simple thing, but it saves me a ton of digging when I want to copy all important media to my computer from the Droid.

    Don't really know what the busybox portion does but it was a part of the script.txt file for the scheduler and doesn't seem to hurt any to have it.

    Thanks!
    1
    To change the lcd density (resolution of phone, lower numbers mean higher resolution) temporarily. Performs a hot reboot into new resolution, I use 200 (makes my X10 look much better) normally but need to change to 240 in order for some apps to work correctly. (Edit ro.sf.lcd_density=240 in /system/build.prop for permanent change.) Needs su true needs to be checked.

    Feature Req: Please could you add widgets that execute scripts on click.
    Code:
    setprop qemu.sf.lcd_density XXX     (XXX chosen density)
    busybox killall system_server

    eg for default (on my X10) resolution
    Code:
    setprop qemu.sf.lcd_density 240
    busybox killall system_server
    eg for resolution I normaly use
    Code:
    setprop qemu.sf.lcd_density 200
    busybox killall system_server
    1
    when i do it manually, i always get some kind of reply, mostly just repeating the commands i typed in (a confirmation?). could this have something to do with why it always errors out with 'stderr:' in GS?

    I doubt it. I've been getting the stderr error for months (GScript hasn't been updated in forever) and it must have something to do with newlines. If you run this script:

    echo hello
    echo world

    the output is:

    stderr:
    echo hello
    stderr:
    echo world
    stderr:

    I don't know any other GScript fix for you. If you use Tasker, you can run the command with the Locale Execute Plugin or if you put all this in a file:

    Code:
    #! system/bin/sh
    mount -o rw,remount /system
    sed -i -e '/mydas.mobi/d' -e '/androidsdk.ads/d' /system/etc/hosts

    put the file in /system/bin, then open a terminal and type "chmod 755 /system/bin/scriptname" then you can open a terminal and type the name of the script to run it. Not much help, but it's a little faster than typing it manually.