I'm currently developing an app using Ionic framework and at some point, I need to access terminal to run a command. In my case, suppose I have an executable file which is named test.sh. normally in terminal, we can run it with ./test.sh (and I'm currently doing this with termux in anroid). Since I am using ionic, I don't have access to terminal nor a file executor. So my question is, how will I be able to execute a shell script using ionic?
Thanks.
Perhaps integrate xterm.js onto your ionic project, which is a js terminal.
Related
Is there a command to install a Cordova app onto an Android device but prevent the app from starting when the installation is finished?
Yes, by using an adb-server and some commands:
First, you have to run:
cordova build android
or if you use ionic:
ionic build android
This command creates an *.apk file(lets call it: this_is_your_apk_file.apk) in your \platforms\android\build\outputs\apk project-directory.
Then you have to go into this directory:
cd path_to_your_project\platforms\android\build\outputs\apk
adb install this_is_your_apk_file.apk
You may have to wait until your device is ready for communicating with the adb-server, but as soon as your device is shown in the device-list by using this command:
adb devices
the commands above should work as described.
Fellows I have made an app by using ionic framework.
When I run
ionic serve
On the terminal it runs as it should be. But when I run it via:
ionic run
I see on the device the app running by displaying the ionic's loading screen, but after that it does not run as it should be.
What I am asking is how can I see - debug any sort of error from the app running on the device in order to figure out what's wrong?
I am using an Adroid device for the tests.
Try this :
ionic run android -c -l
// -c for consolelogs and -l for livereload
After ionic run android command keep fixed to your cable and laptop.
Go to your chrome and type chrome://inspect you can see your app in that and click inspect so that you can able to look what is going on in your mobile app and you can debug it.
You can add additional flags when using ionic run.
-c will show console logs.
-s will show server logs.
-l will perform live reload of the application when code changes.
So you can use something like
ionic run android -cls
Note that for livereload to work if the device is not connected directly make sure its in the same network as the serving device. Make sure to serve to a local IP address in this case (you can use ionic address to change that).
I fixed it by running:
adb logcat | grep 'Web Console'
On a linux terminal / git bash
I'm wondering if Cordova or any plugin for Cordova enables me to execute a command in the android shell? Similar to doing adb shell myCoolBinary -doThisStuff on a desktop machine connected to the phone.
Googling for this only returns tutorials for how to use the Cordova cli desktop application, which absolutely NOT what I'm looking for. I want to execute commands ON the phone.
I ended up writing my own plugin.
I mostly put it together from another question that was about doing root shell executes from within your android app. I just adapted it to cordova.
I don't have the time to make this nice so here is a gist:
https://gist.github.com/PTS93/d78ee885ee0c2f74892434008a953f8c
Just replace the files with the files from this plugin template:
https://github.com/don/cordova-plugin-hello
You can then in your cordova app call this:
shell.execute("your shell command", success, failure);
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.