Questions tagged [scripts]

Scripts are small programs written for a command interpreter or another scripting language.

Filter by
Sorted by
Tagged with
56
votes
7answers
165k views

How can I run a script on boot?

I'm accustomed to running scripts on boot in Linux, but I'm not sure how to do this in Android. I'd like to start my SSH daemon on start, so I'll always be able to connect. How can I run an arbitrary ...
14
votes
2answers
11k views

Start an Android application via a shell script?

Is it possible to start an actual Android application from the command line in Android? For example, say I'd simply like to start/bring to the front my calendar. Is there a way that I can do this like:...
9
votes
2answers
21k views

On Android can I write scripts (similar to Win .bat files) to combine several command line commands?

On Windows, I can run two commands using a .bat file. How can I achieve the same thing on Android For example: update my podcasts by calling pcastclient /updateALL force sync of my pictures ...
9
votes
6answers
19k views

how can I randomize my MAC address every time my WiFi is turned on?

Given the increased prevalence of systems which track people's movements by their Mac addresses I'd like to obscure mine. I have a rooted galaxy note 2 with busybox installed. I can change my MAC ...
6
votes
3answers
20k views

Is there no way to get scripts to run in Android?

Since Android is Linux at its base, I logically think it should be possible to run a script on Android, like a Python script or PHP script (with executable bit obviously). If not conventionally, is ...
5
votes
1answer
10k views

How to run an executable on boot and keep it running?

I have an executable build from a ndk-build program. I want to run it on a rooted Android device. How much is the possibility that Android will kill my executable? Using adb shell, I am able to ...
5
votes
0answers
896 views

ifup/ifdown scripts

I am fiddeling with some network related things and want to try them on Android too. In Ubuntu it was quite easy to run some commands if an interface (eth0 or wlan0) goes up or down by simply adding ...
4
votes
1answer
1k views

How does a update.zip file update files

I have been searching online on multiple sites and could not find one answer to this question, only found one question online but with no answer How does the android recovery update files from a ...
4
votes
4answers
44k views

How can I change my pictures' and videos' date on my phone by their filenames?

Yesterday, I moved a bunch of old pictures and videos to my phone, using a FTP server I installed on my phone. Everything went fine, but today I discovered that the date of all the copied photos and ...
3
votes
4answers
24k views

How do I script my phone?

What I mostly want to do, is quickly alter settings, add alarms etc. It is perhaps called something else? This is from a Windows PC. Language is not important, but I know Python and UNIX scripting. ...
3
votes
2answers
4k views

Where can I run a .sh script on Android without root?

Lately I've been playing around with .sh scripting in Android. At first I used BusyBox and it's integrated scripting utility, though I quickly realised that coding on the phone isn't the best, so I ...
3
votes
1answer
5k views

How to detect GPS status through adb shell?

I need to detect GPS status through adb shell. I have tried dumpsys location command but the output of this command is not changed when the GPS is enabled/disabled.
3
votes
1answer
14k views

Show a piece of a Google Spreadsheet document on Andriod main screen

I have a Google Spreadsheets document that is frequently updated and there are some cells in it that show a kind of short summary. Let it be a 2x2 block of cells that contains two headers and two ...
3
votes
1answer
791 views

init.d doesn't get executed

i am using samsung s2 and a custom rom, external sd card is mounted to /emmc but i want it to mount to /mnt/sdcard/external_sd, how could i mount it using init.d? i made a file called "99mount" with ...
3
votes
1answer
728 views

Can't run any Python script on my Android phone

I have an Acer Liquid Metal, Gingerbread... I've tried installing Python on Android (and s4la: http://code.google.com/p/android-scripting/) but when I run the hello world script I get: dlopen ...
3
votes
1answer
806 views

Commands run on terminal but throw errors in shell script

I created a .sh script which sets app permissions on Android devices. If I push the script on /sdcard and run it through adb shell with command sh ./test.sh, the following error occurs on each ...
3
votes
3answers
4k views

Shell script to kill custom apps, run another app then restart killed apps?

Is it possible to make a shell script that would run using Smanager, for example, to do the following: Kill a list of custom apps loaded from a file Run one custom app loaded from the same file When ...
3
votes
1answer
67 views

find: multiple "-exec" for list of files not working?

I am trying to figure this out on an Android phone running Oreo / 8.0, with toybox 0.7.3-android. I am trying to get a list of files inside a folder and their respective mtime. I am running this ...
3
votes
0answers
592 views

How to run a script on USB OTG Drive?

First up - I do not have any experience at all with programming in Android or Linux environments. So, very sorry if this question sounds stupid. Here is what I am looking for: I use a USB drive in my ...
3
votes
0answers
776 views

Running your own .sh script at vold.decrypt=trigger_shutdown_framework via init.rc (android 5.0)

I want to workaround a vendor bug in an Android 5.0 phone (chinese, MTK, no proper source) Problem is due to a bug in some binary, /data is not properly released on vold.decrypt=...
3
votes
0answers
2k views

How can I change preferred network type through a script (or terminal command)

I'm currently attempting to create a workaround for a problem that is plaguing a ROM that I'm using. While my phone and ROM are capable of using LTE, and use it perfectly fine, the "preferred network ...
3
votes
0answers
1k views

Help with this ADB REVERSE Tethering Script?

I added the functionality to automatically turn on reverse tethering after many fails: Now i only enter t into terminal alias t='r && sz $tether && r && sz $n' tether='am ...
2
votes
1answer
193 views

Android stops/pauses execution of my background script?

Short version: Why is my bash script (running in the background, started via SSHD) not running every ~30 seconds when it should? (NOTE: SSHD and the script are running as root!) I have a script that ...
2
votes
1answer
934 views

Acquire Android image using flash drive OTG

In Linux, the dd command is used to pull the image from the smartphone to computer. And of course, the smartphone need to be rooted before the dd command launched. Is there any specific command or ...
2
votes
1answer
7k views

Run shell script in background process no matter what activity in foreground?

I have a shell script that looks does the following: # /mnt/sdcard/touch.sh sleep 10 while [ 1 ]; do input swipe 700 380 1020 600 1000 input tap 960 540 input swipe 1220 700 900 480 1000 ...
2
votes
1answer
2k views

How to enable "Disable HW overlays" at startup?

Question is simple, is there an easy way to enable developer options on startup from a command line script or 3rd party app? I want to set the flag for 'Disable HW overlays' on startup because it gets ...
2
votes
2answers
3k views

How can I execute a script on the SD card and be able to pass arguments to it?

I tried executing a script on the sdcard as is because on FAT, everything is 777. ./.profile ./.profile: permission denied I added this as the initial command for the Android shell and it executes ...
2
votes
1answer
74 views

How can I Automate for selected apps to only use cellular data and not Wi-Fi... and vise versa?

I tried doing it myself (On Automate) but it's a bit too advanced. Can I get your help? Also, I think Android overriding data connection when wifi is on might have to be factored in. I could use ...
2
votes
1answer
5k views

How to run a script in background from adb shell?

I have a problem with USB tethering on my rooted Nougat phone (LineageOS). After some time phone stops USB tethering. To fix that I run the following script like this: adb shell su nohup sh tether.sh ...
2
votes
1answer
4k views

How to run an Android init service with superuser SELinux context?

I want to run an Android init service. I have a device which has rooted shell (purchased from manufacture as rooted). This device doesn't have Magisk or other su manager but adb shell is rooted and it ...
2
votes
1answer
2k views

How can I run a shell script when some WiFi is connected?

I have a really simple shell script, that just adds a route to my internal development machine. This is useful, as that machine has some LXC containers inside, so I can reach all my containers from my ...
2
votes
1answer
674 views

Run script using init.rc doesn't work

I'm trying to run a script that exectues when the device has finished booting. This particular device does not support running scripts from an init.d directory, which is why I am using init.rc. The ...
2
votes
2answers
459 views

How to automate sending my current battery percentage to PC over the internet every 5 minutes?

I'm using Android 9 on my device, there are many times when I'm away from my phone and it is charging in a different room or someone else is using it, is there was a way to send over the battery ...
2
votes
1answer
663 views

how to display text on TWRP recovery screen using a sh file?

I'm trying to display message on TWRP 3.2.3-0 recovery screen using a .sh file. i was thinking using echo command to make that. my update-script is like this ifelse(is_mounted("/system"), unmount("/...
2
votes
1answer
9k views

Tasker to run scripts in terminal shell

I have searched for this but till now I have not found any tasker that would be able to do this, so I decided to ask here. Till now I have been using Trigger Pro as my favorite tasker but it lacks in ...
2
votes
1answer
2k views

How do i root Android x86_64?

I installed android x86_64 and now I want to root it but all the root scripts are for 32-bit versions of Android. I am using console os lollipop that is not rooted. What are my options? Thanks
2
votes
2answers
10k views

is there a way to run *.sh file by just touching it in a file manager?

I mean like it is when user opens an image file a pane opens where user can select app for given type. But when I'm clicking on *.sh file the first option that shows up is to open as text/audio/video/...
2
votes
2answers
5k views

How can I manage "desktop" icons

I want to remove all the icons on the desktop, (and also in the bottom bar) and place new ones via ADB. My script already removes all the apps, but icons/shortcuts remanin there! Is there any command ...
2
votes
0answers
25 views

Write a script to extract memos?

Is it possible to run a script on Android that would access the Samsung memo app, take each note in there, copy its content, send it somewhere (e.g. an email or just store in a text file) then delete ...
2
votes
1answer
264 views

Scripting app that can listen on notifications [closed]

I'm looking for an app that can run in the background, and listen for a silent notification from a different app (i.e. shows up on notification list but makes no sound) and once it appears, make a ...
2
votes
0answers
1k views

Batch script use sqlite3 to edit settings.db

I want to create batch script to enable hidden languages in a Huawei phone. But every time I stuck can you guys spot where is my problem @echo off color e cd "%~dp0" mode con:cols=90 lines=40 adb ...
2
votes
1answer
2k views

mount in /data/local/userinit.sh is not working

I want to map /sdcard/DCIM to /storage/sdcard1/DCIM using CM 12.1 on a I9100 I wrote those few lines to /data/local/userinit.sh: #!/system/bin/sh log -p i -t userinit "userinit start"; mount -o bind ...
2
votes
1answer
68 views

Share text via HTTP request

I'd like to add an item in the system "Share" menu that sends links and other small text via HTTP POST requests. On my PC i'm using curl + a shellscript.
2
votes
1answer
6k views

How can I successfully run this script on a emulated terminal on Android?

Background I am trying to install Ubuntu onto my Acer Iconia A500 using VNC and this application called Complete Linux Installer. My tablet is rooted and I have found several sources saying they have ...
1
vote
2answers
730 views

How would I automate repetitive tasks in Android?

There are many tasks I do repetitively, like connect a Bluetooth headset or connect to a hotspot. How do I typically "code" this? How do I execute? Is there a consistent library or package manager, ...
1
vote
3answers
11k views

How to create an update.zip file that can copy & rename a file?

Here's exactly what I'm looking for - I need an 'update.zip' file that can copy a file (example): /system/framework/file-to-copy.apk to another folder: /system/ and then it would rename the 'file-...
1
vote
1answer
1k views

adb pull says it pulled all of the files from my Android phone into my Windows PC but in reality it didn't

So I am using adb to copy all of my Android files to my Windows PC with this command: adb pull -a /mnt/sdcard C:\backup And when it's done it says all x amount of files have been pulled, I can ...
1
vote
4answers
5k views

Home screen icon for terminal program?

I'm using terminal-ide http://code.google.com/p/terminal-ide/ which is basically a terminal for android with all sorts of utilities. One is able to create bash scripts for example. Is there a way to ...
1
vote
1answer
107 views

Staging of several android devices made simple

I have to stage several android dongles to comply to my company’s need. I need to setup the WiFi, google account, download 3/4 apps, configure them, change background picture... i’v been Trying to ...
1
vote
1answer
6k views

Reason for chroot failure: tmp-mksh: chroot: not found

Introduction: I formatted a SDCard in ext4 and copied an ArchVersion on it to run it from Android like in this guide (step 6). Of course my device is rooted and am running the following scripts and ...