I installed python 2.7 in my Android device and I tried executing a python script by typing the command in terminal emulator. The problem is that although I use the full path for python the following error appears:
link_image[1997]: failed to link ./python CANNOT LINK EXECUTABLE.
I tried to add environment variables in ./~bashrc but I didn't make it. Any idea ?
OK it is solved. I followed these steps (http://code.google.com/p/python-for-android/wiki/RunPythonFromShell) but first I had to put the file standalone_python.sh in /data/ because in sdcard I had no permission to execute. And finally using 'su' I made it to run my script as root.
Related
I'm getting a permission denied error when my QPython android script tries to launch another qpython script.
I'm assuming that this can be done - right?
I've tried subprocess.call, whic seems like the right thing to do.
But, the script doesn't run, and the log shows the permission denied error.
The obvious thing to do is look at the permissions of the sub script, but I don't know how to do that on my Android phone.
Any comments/suggestion appreciated.
Thanks.
First, how to open a command prompt(bash)
Actually qpython = terminal emulator + Python code editor + Python interpreter.
So of course you can use the console! Why you can't enter bash is because every time you click the console icon in qpython it runs python. Just type something which will cause the interpreter error like "I want bash!" then run it, interpreter will break then go back to bash.
Second, how qpython run your script
It pass your python script to a shell script(qpython.sh), then run the your script by a python interpreter.
Third, about the permissions
Why permission denied? You can't run a python script directly because it's not marked as executable. But you can pass the script's path to python interpreter to run it.
Finally, so how to call a python script by a python script in qpython?
#-*-coding:utf8;-*-
#qpy:2
#qpy:console
import subprocess
print("I am calling myself!")
pysh="/data/data/org.qpython.qpy/files/bin/qpython-android5.sh"
#if U R using android 5
#else
pysh="/data/data/org.qpython.qpy/files/bin/qpython.sh"
callpy=__file__
#the script path you want to run
subprocess.call([pysh,callpy])
Hope this help you!
(I can't add image by myself because I don't have that much reputation, I need someone else to change my image link to image. So if you like my answer, please vote me. Thanks.)
Once you know where the script is, just move to that folder and then use the following command to list the files:
ls -l
the command outputs all the files together with permission (first column).
Now, to change the permission to "execution" you can use:
chmod 755 [your-script-name]
I'm trying to integrate Google Sign-in into my app, and I'm following this tutorial. However, I'm trying to add the configuration file to my project, and the tutorial says that I should use this command:
$ move path-to-download/google-services.json app/
When I open the terminal in Android Studio and write the command it says:
'$' is not recognized as an internal or external command
I've also noticed that it's similar to Command prompt (I'm using Windows). Can I just copy the .json file and paste it in my app folder?
I believe $ (dollar sign) is indicating a start of new line in Unix based OS terminal. In Windows OS, the command should be
MOVE [Source] [Target]
For more information, check this link.
Or you can just copy and paste it in your app folder. That will be suffice as well as.
'$' is the user prompt, You should omit the '$' and the command should work
I am trying to run Android's MonkeyRunner but having problems running it from my Git Shell.
When I run:
monkeyrunner.bat
it gives me this error.
$ monkeyrunner.bat
/c/AndroidSDK/tools/monkeyrunner.bat: line 1: #echo: command not found
/c/AndroidSDK/tools/monkeyrunner.bat: line 2: syntax error near unexpected token `('
/c/AndroidSDK/tools/monkeyrunner.bat: line 2: `rem Copyright (C) 2010 The Android Open Source Project'
How do I fix this? I tried running my script with it too but still same error.
Thanks in advance!
The git-shell is a login shell for SSH accounts to provide restricted Git access.
It permits execution only of server-side Git commands implementing the pull/push functionality, plus custom commands present in a subdirectory named git-shell-commands in the user’s home directory.
Therefore, if you don't have monkeyrunner (notice, not .bat or .sh here) setup in the git-shell-commands you won't be able to run it.
I have HTC One X, with Android 4. I have install sl4a, python, scapy and terminal IDE on my smartphone. All is alright, python in terminal IDE work well with scapy as root.
The problem happens when i use SL4A.
droid=android.Android(('127.0.0.1', '58322'))
droid.makeToast('Hello, Android!')
When i run the script there is no error, but at interpretation of makeToast() the program stops and nothing happens.
Anyone can help me to run a python script as root with SL4A in Terminal ?
I can tell you how to run it as root, but first let me mention that I do not believe that this is your issue. To make sure, try running this script:
# author: Matthew Downey
# purpose: Hello World.py script for android with SL4A
import android #this makes sure you can run android functions
droid = android.Android()
droid.makeToast('Hello, Android!') #uses the android module to display a user message
This should run fine, and does not require root. However if you are running a python script on your android that does require root (say you are using subprocess.call(command) to execute a command that requires root), try this (from the terminal on your android):
app_148#cdma_spyder:/ $ cd filepath_to_mypythonprogram/myProgram.py
app_148#cdma_spyder:/ $ su
app_148#cdma_spyder:/ # python myProgram.py
This should effectively run the python script as root, assuming your phone is rooted!
This might be of help: https://groups.google.com/forum/?fromgroups=#!searchin/python-for-android/socket.gaierror/python-for-android/s1rX9fTYPQQ/6_pHEm13gQwJ
Also your port shouldn't be in single quotes.
To make use of ASL library for my screen shot app on android,i need to install a script file (run.ps1) and run it on emulator ... So can any one tell me how can i do it...should i do it using ADB or using Eclipse...?
A .ps1 file appears to be a PowerShell script. PowerShell is a Windows application. Android is not Windows. Hence, if it is indeed a PowerShell script, you cannot run that script on Android.