[APP] Gscript * Easily launch/save shell scripts from within Android UI *

Search This thread

rogro82

Retired Senior Recognized Developer
May 1, 2008
862
445
plus.google.com
2013-05-17 ( 1.0.0-alpha3 )

New features:

* Basic terminal emulation ( input handling, color support, cursor control ) etc.

The terminal has 2 gesture modes ( scroll, cursor ) and additional soft-input methods for keys like ctrl, escape etc.

Scroll-mode:
Normal scrolling, auto-scrolling and fast-scrolling (right-edge), double tap on top/bottom to jump.

Cursor-mode:
Edges of the screen will send d-pad (up/down/left/right) keys ( multiple pointers/fingers to control speed of repetition ).
Swipe up/down for page-up, page-down and swipe left/right for home and end keys.

Currently the emulator has no utf-8 support and some other features might be missing.

* The ability to start a terminal/process directly.

* The ability to create aliases directly to a profile.

Enabling an alias will add a shortcut in the launcher directly to the selected profile.
Currently 3 aliases can be set (terminal, su, sh). Sadly android is pretty limited in this area and it only allows enabled/disabling of components so there is no way to change titles, but i guess these 3 are most common. Be aware that you might need to re-start your launcher/phone before changes are visible ( this also depends on the launcher active ).

* Updated icon.

Notice:
Because of major changes happening during the alpha-state it is required to do a reinstall instead of an upgrade ( because of possible database/preference changes ).


2013-04-12 ( 1.0.0-alpha2 )

- Cleanup of list items in the history tab ( date/time added ).
- Basic history view which shows the history transcript and allows to email it.
- Ability to create desktop shortcuts from library items added ( contextual actionbar of an item ).
- If a input dialog (gscript-input) is dismissed it now shows a notification that there is a input request pending and clicking it will bring the user straight back to the dialog.

2013-04-10 ( 1.0.0-alpha1 )

Gscript is currently in an alpha state so features might be missing or broken.

The current progress:

Basics of the new library interface.

Scripts are no longer stored within gscript but instead access is now handled through libraries.
Basically the library decides how to browse through files and get their content and the only thing
that is stored within gscript are the additional item attributes and conditions.

Currently this is limited to a LocalStorage library type, but other options might come later on.

Basic process / history management.

Processes now run in a background service and can be accessed through the 'active'-tab in gscript or
by clicking on their notification (if enabled).

Custom shell profiles ( editable in settings )

Instead of a fixed option for sh / su you can now create Shell Profiles which allow changing of the actual
command including color schemes and additional extras like path appending etc.

Launching scripts directly from most file managers ( if they handle files the way they should... Astro works for me )

Launching scripts from anywhere else (terminal, adb etc) using gscript-exec ( found in /data/data/org.gscript/bin )

First start on the dialog framework to allow graphical user input from shell using gscript-input, which should also work outside gscript.
Very minimal console view ( output only and no input methods yet )

What is WIP:

A lot...

A decent console view which will allow user input
History tab only shows the files that have been executed but no way to see the output, time etc
Additional features to the library interface to edit scripts etc
Additional features to the dialog framework ( to allow file selection etc, numeric input )
Additional item conditions like schedules ( now only has a boot condition )
Desktop shortcuts / widget
Backwards compatibility to android 2.2 ( now 2.3 )

More...

Who should install this?

Users who want to help make this better and can live with the fact that things might not be 100% finished

How to start?

Install
Within Gscript click the + sign in the action bar to add a new library.
Select Local Storage
Give the Library a name
And set the path to a folder you want as the root view ( It does not create the folder so make sure it exists ).
Browse the folder from within Gscript and click an item to execute or long click an item to set attributes/condtions ( shell, boot etc )

In settings new Shell profiles can be created or deleted and a default can be set.

The command-line of a shell profile can have %path% in it. If this is the case it will replace this with the final executable script.
If it does not have a %path% argument the script will be send as input.

The binaries gscript-exec, gscript-input can be found in /data/data/org.gscript/bin ( if everything went right and it is a supported ABI )

Usage
gscript-exec filename

gscript-input types
will list available input types

gscript-input [type]
will list the expected arguments

Sample script which uses gscript-input

Code:
# items are ; seperated key:value pairs
# keys with a * prefix are pre-selected
# in case of radiobuttons only the first
# selected item will actually get selected

RESULT=$(gscript-input \
		list \
		"Choose" \
		"Select multiple" \
		"0:The first option;
		 *1:The second option;
		 *2:The third option;
		 *3:The last option;")

gscript-input \
	toast \
	"Selected items: $RESULT"

echo "Selected: $RESULT"

SELECTED=$(gscript-input \
		list \
		"Choose" \
		"Select single" \
		"0:The first option;
		 *1:The second option;
		 2:The third option;
		 3:The last option;" \
		radio)

if [ $? -eq 1 ]; then
	gscript-input \
		toast \
		"You selected $SELECTED"
fi

echo "Selected: $SELECTED"

NAME=$(gscript-input \
		text-entry \
		"Name" \
		"Please enter your name")

if [ $? -eq 1 ]; then 
	gscript-input \
		dialog-info \
		"Welcome" \
		"Welcome back $NAME"
	
	echo "$NAME"
fi

gscript-input \
	dialog-message \
	"Finished" \
	"Finished processing script.. do you want to exit now?" \
	yesno

if [ $? -eq 1 ]; then
	gscript-input \
		toast \
		"Goodbye $NAME"
	exit
fi



* In case of issues please be clear and give as many details as possible.
* During the alpha-state i will keep multiple versions available for download ( so be sure to check version numbers ).
* During the alpha-state it is required to do a re-install instead of an upgrade ( because of possible breaking changes ).
 

Attachments

  • device-2013-04-07-043837.resized.png
    device-2013-04-07-043837.resized.png
    59.9 KB · Views: 9,326
  • device-2013-04-07-043859.resized.png
    device-2013-04-07-043859.resized.png
    59.3 KB · Views: 7,653
  • device-2013-04-07-044002.resized.png
    device-2013-04-07-044002.resized.png
    51.9 KB · Views: 6,926
  • device-2013-04-07-044015.resized.png
    device-2013-04-07-044015.resized.png
    59.2 KB · Views: 5,723
  • device-2013-04-07-045805.resized.png
    device-2013-04-07-045805.resized.png
    60.3 KB · Views: 5,646
  • device-2013-04-07-045905.resized.png
    device-2013-04-07-045905.resized.png
    35.7 KB · Views: 5,413
  • device-2013-04-07-045927.resized.png
    device-2013-04-07-045927.resized.png
    127.3 KB · Views: 5,075
  • device-2013-04-07-050131.resized.png
    device-2013-04-07-050131.resized.png
    141.7 KB · Views: 4,792
  • device-2013-04-07-050214.resized.png
    device-2013-04-07-050214.resized.png
    27.8 KB · Views: 4,575
  • gscript_1.0.0-alpha1.apk
    888.8 KB · Views: 10,313
  • gscript_1.0.0-alpha2.apk
    913.5 KB · Views: 3,568
  • gscript_1.0.0-alpha3.apk
    972.9 KB · Views: 16,459
  • device-2013-05-17-035452.resized.png
    device-2013-05-17-035452.resized.png
    60.9 KB · Views: 4,600
Last edited:

rogro82

Retired Senior Recognized Developer
May 1, 2008
862
445
plus.google.com
Ok ive created an apk.. Ill update the first post with the zip-file attached.

Please be aware that its still beta and that executing scripts without knowing what they do could harm your system!

I just use it to execute "reboot", "tether start/stop", but you can use it to just execute any shell script either as normal shell or as su.

Let me know if it works and if its usefull for anyone.. thanks.
 

Gimpeh

Senior Member
Feb 25, 2009
1,306
9
Springfield
I must be missing something. I put in the script to launch Debian but it dosent appear to launch. Its just a simple command-

cd /sdcard/debian
su
modprobe ext2
su ./bootdeb

Any suggestions?
 

rogro82

Retired Senior Recognized Developer
May 1, 2008
862
445
plus.google.com
you shouldnt need the su commands as you are executing it as su... havent tested multilines a lot other then a few simple calls, but maybe thats where it goes wrong.

Can you try making one .sh file and execute that from within the script field?

That actually how i intended it... that way you can easy backup your larger scripts without having to rely on the database used in my app.

So i just use the commands "tether start" and "tether stop" and leave the actual scripts intact.

Or try it without the su commands and do something like this:

/sdcard/debian/modprobe ext2
/sdcard/debian/bootdeb

Let me know if it works else ill look further into it.
 

rogro82

Retired Senior Recognized Developer
May 1, 2008
862
445
plus.google.com
Ok ive been thinking a bit last night and ill add the following features:

Load from file ( from sdcard .sh files )
Create shortcut ( will create a shortcut to the specified script on the home screen )
Save to file ( will save specified script to sdcard )

Ill also change some things in how things are executed to make it more stable ( im going to save the selected script into a temporary .sh file and execute that one ).
 

rogro82

Retired Senior Recognized Developer
May 1, 2008
862
445
plus.google.com
Ok ive made some changes:

* Added ability to create a shortcut to a script from the home screen ( long press home screen -> shortcut -> gscript and then select the script you want to create a shortcut of )

* Added ability to save the selected script to sdcard as .sh file

* Changed the way scripts are executed. The script is now first saved to /sdcard/gscript_tmp.sh and then executed using either sh or su.

Todo:

Load .sh files from sd.

Ill update the first post with a new zip and the latest changes.
 

rogro82

Retired Senior Recognized Developer
May 1, 2008
862
445
plus.google.com
New zip file in the first post... and also added some screenshots so people know what it does.

New code is also committed to the source repository.

Let me know if all is working ok.
 
Last edited:

benmyers2941

Senior Member
Oct 26, 2007
368
8
Phoenix, AZ
Hi all,

Ive created a small application, for people like me who dont like typing the same thing over and over. I use it for things like tethering and reboot.

Its basically a small database in which you can save your scripts and run them easily from within Android ( either with normal shell or su ).

Ive decided to make it open source ( project can be found on google code, a link is listed below ), so people don't have to be afraid something else is executed as root.
[/URL]


Damn you beat me to it! I've been working on this exact same thing but I've not had much free time lately (I have a two month old at home). I think the only thing that I'd planned that I'm not sure if you've integrated is the abaility to import scripts, so a *nix guru could write a script and share it with others, and for other applications to call a script via this application. Still AWSOME! :D
 

rogro82

Retired Senior Recognized Developer
May 1, 2008
862
445
plus.google.com
Damn you beat me to it! I've been working on this exact same thing but I've not had much free time lately (I have a two month old at home). I think the only thing that I'd planned that I'm not sure if you've integrated is the abaility to import scripts, so a *nix guru could write a script and share it with others, and for other applications to call a script via this application. Still AWSOME!

Todo:

Load .sh files from sd.
:)

Ill add that feature tonight or tomorrow but its coming soon... the shortcut feature took most of my time so didnt had time to complete loading ( although I already started some work on it )

About the calling script from within other applications. I dont know if people would like having other apps running script and as other apps dont know what script a user has its almost impossible to create a solid solution. So yes it is possible, but if its actually workable is another thing.

Glad you like it!
 
Last edited:

texasaggie1

Senior Member
Aug 10, 2004
739
247
oops sorry

When I downloaded gscript.zip on my iMac it unpacked it as a folder. Stupid Mac...

Anyway here is the link to the .apk file for people on their androids....
 

rogro82

Retired Senior Recognized Developer
May 1, 2008
862
445
plus.google.com
Added the ability to load .sh files from the sdcard.

Just put your .sh file in the root of the sdcard and add or edit a script and select "Load file". You will now see the file. Click it and the content of the file will be used as the script.

This way you can easily create .sh files on your pc or share them and eventually execute them as shortcuts :)

Update is in the first post... About to upload the source to the repository
 

Top Liked Posts

  • There are no posts matching your filters.
  • 17
    2013-05-17 ( 1.0.0-alpha3 )

    New features:

    * Basic terminal emulation ( input handling, color support, cursor control ) etc.

    The terminal has 2 gesture modes ( scroll, cursor ) and additional soft-input methods for keys like ctrl, escape etc.

    Scroll-mode:
    Normal scrolling, auto-scrolling and fast-scrolling (right-edge), double tap on top/bottom to jump.

    Cursor-mode:
    Edges of the screen will send d-pad (up/down/left/right) keys ( multiple pointers/fingers to control speed of repetition ).
    Swipe up/down for page-up, page-down and swipe left/right for home and end keys.

    Currently the emulator has no utf-8 support and some other features might be missing.

    * The ability to start a terminal/process directly.

    * The ability to create aliases directly to a profile.

    Enabling an alias will add a shortcut in the launcher directly to the selected profile.
    Currently 3 aliases can be set (terminal, su, sh). Sadly android is pretty limited in this area and it only allows enabled/disabling of components so there is no way to change titles, but i guess these 3 are most common. Be aware that you might need to re-start your launcher/phone before changes are visible ( this also depends on the launcher active ).

    * Updated icon.

    Notice:
    Because of major changes happening during the alpha-state it is required to do a reinstall instead of an upgrade ( because of possible database/preference changes ).


    2013-04-12 ( 1.0.0-alpha2 )

    - Cleanup of list items in the history tab ( date/time added ).
    - Basic history view which shows the history transcript and allows to email it.
    - Ability to create desktop shortcuts from library items added ( contextual actionbar of an item ).
    - If a input dialog (gscript-input) is dismissed it now shows a notification that there is a input request pending and clicking it will bring the user straight back to the dialog.

    2013-04-10 ( 1.0.0-alpha1 )

    Gscript is currently in an alpha state so features might be missing or broken.

    The current progress:

    Basics of the new library interface.

    Scripts are no longer stored within gscript but instead access is now handled through libraries.
    Basically the library decides how to browse through files and get their content and the only thing
    that is stored within gscript are the additional item attributes and conditions.

    Currently this is limited to a LocalStorage library type, but other options might come later on.

    Basic process / history management.

    Processes now run in a background service and can be accessed through the 'active'-tab in gscript or
    by clicking on their notification (if enabled).

    Custom shell profiles ( editable in settings )

    Instead of a fixed option for sh / su you can now create Shell Profiles which allow changing of the actual
    command including color schemes and additional extras like path appending etc.

    Launching scripts directly from most file managers ( if they handle files the way they should... Astro works for me )

    Launching scripts from anywhere else (terminal, adb etc) using gscript-exec ( found in /data/data/org.gscript/bin )

    First start on the dialog framework to allow graphical user input from shell using gscript-input, which should also work outside gscript.
    Very minimal console view ( output only and no input methods yet )

    What is WIP:

    A lot...

    A decent console view which will allow user input
    History tab only shows the files that have been executed but no way to see the output, time etc
    Additional features to the library interface to edit scripts etc
    Additional features to the dialog framework ( to allow file selection etc, numeric input )
    Additional item conditions like schedules ( now only has a boot condition )
    Desktop shortcuts / widget
    Backwards compatibility to android 2.2 ( now 2.3 )

    More...

    Who should install this?

    Users who want to help make this better and can live with the fact that things might not be 100% finished

    How to start?

    Install
    Within Gscript click the + sign in the action bar to add a new library.
    Select Local Storage
    Give the Library a name
    And set the path to a folder you want as the root view ( It does not create the folder so make sure it exists ).
    Browse the folder from within Gscript and click an item to execute or long click an item to set attributes/condtions ( shell, boot etc )

    In settings new Shell profiles can be created or deleted and a default can be set.

    The command-line of a shell profile can have %path% in it. If this is the case it will replace this with the final executable script.
    If it does not have a %path% argument the script will be send as input.

    The binaries gscript-exec, gscript-input can be found in /data/data/org.gscript/bin ( if everything went right and it is a supported ABI )

    Usage
    gscript-exec filename

    gscript-input types
    will list available input types

    gscript-input [type]
    will list the expected arguments

    Sample script which uses gscript-input

    Code:
    # items are ; seperated key:value pairs
    # keys with a * prefix are pre-selected
    # in case of radiobuttons only the first
    # selected item will actually get selected
    
    RESULT=$(gscript-input \
    		list \
    		"Choose" \
    		"Select multiple" \
    		"0:The first option;
    		 *1:The second option;
    		 *2:The third option;
    		 *3:The last option;")
    
    gscript-input \
    	toast \
    	"Selected items: $RESULT"
    
    echo "Selected: $RESULT"
    
    SELECTED=$(gscript-input \
    		list \
    		"Choose" \
    		"Select single" \
    		"0:The first option;
    		 *1:The second option;
    		 2:The third option;
    		 3:The last option;" \
    		radio)
    
    if [ $? -eq 1 ]; then
    	gscript-input \
    		toast \
    		"You selected $SELECTED"
    fi
    
    echo "Selected: $SELECTED"
    
    NAME=$(gscript-input \
    		text-entry \
    		"Name" \
    		"Please enter your name")
    
    if [ $? -eq 1 ]; then 
    	gscript-input \
    		dialog-info \
    		"Welcome" \
    		"Welcome back $NAME"
    	
    	echo "$NAME"
    fi
    
    gscript-input \
    	dialog-message \
    	"Finished" \
    	"Finished processing script.. do you want to exit now?" \
    	yesno
    
    if [ $? -eq 1 ]; then
    	gscript-input \
    		toast \
    		"Goodbye $NAME"
    	exit
    fi



    * In case of issues please be clear and give as many details as possible.
    * During the alpha-state i will keep multiple versions available for download ( so be sure to check version numbers ).
    * During the alpha-state it is required to do a re-install instead of an upgrade ( because of possible breaking changes ).
    5
    Edit:

    Updated to first post
    5
    Im sorry that I have not been able to do as much work lately because of back problems and a very busy schedule.

    I will focus on getting a first version up and running so that people with 4.x can continue using gscript and after that ill continue work on the other features.
    4
    Hopefully ill have an update this week

    Some new features:

    Basic terminal emulation ( input handling, color support, cursor control ) etc.
    The terminal has 2 gesture modes ( scroll, cursor ) and additional soft-input methods for keys like ctrl, escape etc.

    Scroll-mode:
    Normal scrolling, auto-scrolling and fast-scrolling (right-edge), double tap on top/bottom to jump.

    Cursor-mode:
    Edges of the screen will send d-pad (up/down/left/right) keys ( multiple pointers/fingers to control speed of repetition ).
    Swipe up/down for page-up, page-down and swipe left/right for home and end keys.

    The ability to start a terminal/process directly.

    The ability to create aliases directly to a profile. Enabling an alias will add a shortcut in the launcher directly to the selected profile.
    Currently 3 aliases can be set (terminal, su, sh). Sadly android is pretty limited in this area and it only allows enabled/disabling of components so there is no way to change titles, but i guess these 3 are most common.

    Can't wait to see the source!
    Please let us know when you share it.

    As soon as Gscript will get out of alpha/development state it will go up on github, but at this moment too much core features are still being worked out.
    4
    As you might know, silent executing mode will be so valuable.:)

    I totally agree.

    Its still a big work in progress, but some of the key features are:

    Scripts are now handled from within a service, they can run un-attended (silent) and it will just show a notification in the statusbar ( which can be clicked to view the running task ).

    Executing .sh files directly from within a filemanager ( tested with astro and cyanogenmods filemanager ).

    Graphical input support ( text input, dialog options eg yes/no/cancel etc )