This is not yet another post on android-scripting project or SL4A or python for android.
This post is for a specific purpose to empower the terminal again and make users again feel the power of terminal.
Current state we can run perl, python, PHP, ruby, beanshell in SL4A interface or as a standalone apk with modifications.
so here is the bad part
1) you can’t run applications on console directly.
2) you have environmental limitations.
3) you can’t pass command-line arguments.
for a normal person these could be some limitations however for some including myself THESE are the limitations.
so while searching for solution i have came across this script
Here is a modified version of the same making sure the awesomeness embedded
#License: GPLv2 or later #License URI: http://www.gnu.org/licenses/gpl-2.0.html PW=`pwd` export EXTERNAL_STORAGE=/mnt/sdcard export LANG=en PYTHONPATH=/mnt/sdcard/com.googlecode.pythonforandroid/extras/python PYTHONPATH=${PYTHONPATH}:/data/data/com.googlecode.pythonforandroid/files/python/lib/python2.6/lib-dynload export PYTHONPATH export TEMP=/mnt/storage/com.googlecode.pythonforandroid/extras/python/tmp export PYTHON_EGG_CACHE=$TEMP export PYTHONHOME=/data/data/com.googlecode.pythonforandroid/files/python export LD_LIBRARY_PATH=/data/data/com.googlecode.pythonforandroid/files/python/lib cd $PW /data/data/com.googlecode.pythonforandroid/files/python/bin/python "$@"
Line no 1,3,11 are the changes that i made.
These changes allow for following things.
1) allow us to use this shell script to call python.
2) allows for command line argument passing.
3) relative path references are now working
however we also need to understand the importance of Sl4A style project these project provide native applications a direct option to interact / create native UI. (dialog box, button, texts etc)
I have named this script as py and placed it in /system/bin/py location
so basically copying this script in a text file say py.txt
adb push py.txt /system/bin/py
adb shell chmod 04755 /system/bin/py
gives you python shell on your android terminal.
Right now i am working towards making various tools of trade available on terminal.
I will be keeping a track my progress at XDA developer forum thread linked here.
Thanx for the info anant, i was stuck to this problem from last 4 months, you solved it… Thanx a ton…
I got ruby sort of statically compiled … http://rmccurdy.com/stuff/G1/BINS/ some other bins in there too ..
Pingback: Python in Terminal IDE for Android
Pingback: Standalone Perl on Android | Anant Shrivastava : Techno Enthusiast
When I directly copy&pasted the code into my android phone, each line ended with a “^M” if opened the file with vi. In this case the code may not work following the instruction. After confused for quite some hours I removed the ^M and everything works like a charm.
The text file has to be in unix format.
so just like what you did, you could have done a dos2unix file format conversion also.
Thanks
Please, help me. I did everything what you wrote on xda-developers but when I do:
cd /sdcard/sl4a/scripts
py hello_world.py
it say “: bad variable name”
What i did wrong? (I don’t know much about shell, so maybe I have to write it in other format – ex. with “” or something like that?)
Original Python standalone script (https://code.google.com/p/python-for-android/source/browse/python-build/standalone_python.sh) works fine…
Looks like my code is now outdated and original script is updated with correct code. so please use the original script. I don’t have the need of this script at this point and hence not finding much time to work on this at this point in time.
I may get some time and update this in future but as of now this is what it is.
Thanks for stopping by and placing the comment and also thanks for trying the script.