I run python in my Android Terminal and want to run a .py file with:
python /sdcard/myScript.py
The problem is that python is called in my Android enviroment indirect with a shell in my /system/bin/ path (to get it direct accessable via Terminal emulator).
My exact question, how the title tells how to pass parameter through multiple Shell scripts to Python?
My direct called file "python" in /System/bin/ contains only a redirection like:
sh data/data/com.hipipal.qpyplus/files/bin/qpython-android5.sh
and so on to call python binary.
Edit:
I simply add the $1
parameter after every shell, Python is called through like:
sh data/data/com.hipipal.qpyplus/files/bin/qpython-android5.sh $1
so is possible to call
python /sdcard/myScript.py arg1
and in myScript.py as usual fetch with sys.argv
thanks
I don't have experience in Android programming, so I can only give a general recommendation:
Of course the naive solution would be to explicitly pass the arguments from script to script, but I guess you can't or don't want to modify the scripts in between, otherwise you would not have asked.
Another approach, which I sometimes use, is to define an environment variable in the outermost scripts, stuff all my parameters into it, and parse it from Python.
Finally, you could write a "configuration file" from the outermost script, and read it from your Python program. If you create this file in Python syntax, you even spare yourself from parsing the code.