• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

How to pass variables to a python script?

mapamapa

Lurker
So I've been trying to do this: http://tasker.wikidot.com/email
The problem is that there is no (Misc / Run Script) in my tasks, maybe because the Tasker app has been updated? The only thing I can find is (Plugin/SL4A) but there's no option to pass variables there.

Help please!
 
Oh thank you!
That was too easy, didn't look hard enough. :D

I'm doing the "if someone fails to unlock my phone, take a photo of them and send the picture to my email".
 
Thom is right, I have mine setup to do the exact same thing with sendemail.py, using Action->Code->Run SL4A Script, when doing so there'll be a Pass Variables Section in the Tasker dialog.
 
Thanks, but it still doesn't work.
Python 2.6.2 is showing under interpreters in SL4A and the example scripts are showing. Can't run any of them though. :/

edit: The logs after trying to run the scrips are completely empty..
 
Last edited:
How are you trying to run them, from a terminal or from Tasker.

If from a terminal you have to setup the environment first. I used this bash/shell script on my Note 4 to run python from a terminal.
Code:
#!/system/bin/sh

# Already Set !
#export EXTERNAL_STORAGE=/storage/emulated/legacy
PYTHONPATH=/storage/emulated/legacy/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
/data/data/com.googlecode.pythonforandroid/files/python/bin/python "$@"

Which I adapted to the Note 4 by altering the paths from this original, you'd have to setup the paths for your device.
Code:
#! /bin/sh

export EXTERNAL_STORAGE=/mnt/storage
PYTHONPATH=/mnt/storage/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
/data/data/com.googlecode.pythonforandroid/files/python/bin/python "$@"
 
Forgot about the SL4A runner, just played with mine, when selecting a script it popped up some options, I just chose the terminal icon and they ran no probs. I can't think what's wrong with your install if that doesn't work, sorry.
 
Back
Top Bottom