Hot answers tagged

12

Python/PHP specific If you are asking specifically for Python and PHP scripts, SL4A probably is your best choice (though there are other Python supporting apps in the playstore, like e.g. QPython Lite). And if you want to automate things, you might want to take a look at the SL4A Script Launcher (in connection with TaskBomb task scheduler) as well. Shell ...


6

How about Chainfire's tool Pry-Fi which was announced over at XDA? It works great and it is available via the official Google play-store at: https://play.google.com/store/apps/details?id=eu.chainfire.pryfi Here’s a screenshot showing the tool in action…


6

Well it's obviously not #2, updates would not work so well if they could not update existing items. The script as a whole might do #1, but package_extract_* does #3. You can see the code here: https://android.googlesource.com/platform/bootable/recovery/+/7d0542f28045640dfab6a259ae7bd796e653d66f/updater/install.c


6

How much is the possibility that Android will kill my executable? Privileged native processes usually don't get killed by Android except if they can't handle an error occurred inside, such as some system resource not available or permission denied because of SELinux etc. To free up memory, Android only kills processes within its framework i.e. running under ...


5

/storage/emulated/0 is usually mounted in a way that prevents execution of programs from this location. Therefore even with a set executable bit for your script you won't be able to execute it directly. Of course you can still execute it via sh: /system/bin/sh /storage/emulated/0/test.sh Alternatively there is the directory /data/local/tmp which is ...


5

Android turns off some of CPUs and/or don't let apps use them when it's dozing. It's achieved through Linux kernel's Control Groups. One of the cgroups is cpuset that controls which CPU is assigned to which processes. Android creates multiple descendant cgroups in cpuset e.g. background, foreground, system-background, top-apps etc. Apps are normally in ...


4

It worked by just doing sh /mnt/sdcard/touch.sh & after having started a shell with adb shell. Then, when I closed the terminal forcibly while the process was in the background, the process remained running in the background of my phone as expected. I was able to kill the process later by getting with adb shell the using ps to find the process ID and ...


4

Is there any specific command or script to be put on the flash drive, to acquire image of Android smartphone and store the acquired image to the flash drive On-The-Go? Nope. No special command or script is needed other than cat or dd, the binaries thankfully Android comes with. Often, the auto mount point of a flash drive is /mnt/usbotg (may differ for ...


4

Actually you can do that by using the run_program syntax in updater-script to execute a shell script that moves/copies/pastes files while in recovery. But of course, you must extract the files that are to be pasted in somewhere (/tmp for instance). Part of the updater-script: package_extract_dir("stuff", "/tmp/stuff"); set_perm(0, 0, 0755, "/tmp/stuff/...


4

Look to /etc/ directory. Usually it is placed in /system/ partition which you can mount as RW: $ ls -l /etc lrwxrwxrwx 1 root root 11 Jan 1 2009 /etc -> /system/etc $ su $ mount -o remount,rw /system $ chmod o+w /system/etc # for "adb push" Some above steps may be replaces with: $ adb root $ adb remount and later remount RO: $ chmod o-w /system/etc ...


4

As you write you know Unix scripting, you might want to take a look at apps like SH Script Runner, Script Manager, Script Kitty, and similar. They all allow you to run shell scripts on your Android device. Also, you could utilize Tasker: create a task to run a script, and then create a shortcut to that task on your homescreen. So you have easy access to ...


4

You want SL4A. From the website: Scripting Layer for Android (SL4A) brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreters directly on the Android device. These scripts have access to many of the APIs available to full-fledged Android applications, but with a greatly simplified interface ...


4

You can use this command: adb shell settings get secure location_providers_allowed Possible outcomes: returns nothing, implying the GPS is switched off. gps,wifi,network or gps,network -- High accuracy mode wifi,network or network only -- Battery saving mode gps -- Device only


4

Just pulling all files via adb to a WIndows computer has multiple problems: Android/Linux allows multiple files in one directory that just differ in their case. The file-system on Linux allow characters in file- and directory names that are disallowed on Windows Some file-names are completely disallowed on Windows which are just regular file-names on Linux/...


3

Is there a way to create an icon on the home screen that will launch one of these scripts? There is another way (other than this one) if you happen to use Terminal Emulator for Android app. It allows a widget which can be used to execute a script. Install that app, choose Term Shortcut widget in your current launcher. Corresponding to Arguments enter: sh ...


3

One thing I haven't seen mentioned yet is SL4A, the Scripting Layer for Android. This allows you run various types of scripts on your phone, Python scripts being one of them. Since SL4A isn't directly in the Play store, you may want something like QPython instead (which incorporates SL4A). Tasker, also mentioned by Izzy, has the ability to launch SL4A ...


3

You could do that using e.g. Tasker, the mighty automation tool: Condition: Monitor Start (i.e., Tasker was started; alternatively: Device Boot, i.e. boot process finished) Task: Run Shell, with your command as parameter If you like it more fancy, you could even use Variable Randomize to generate a different MAC each time...


3

Your SD card isn't prepared at the time that the bind command is executed, because the mounting process hasn't ended yet. To bind, you have to wait several seconds for the mounting of SD card & external SD to be finished. #!system/bin/sh sleep 10 n="$(dumpsys mount | grep -c 'external')" until [ $n -eq 1 ] do sleep 1 n="$(dumpsys ...


3

Many thanks to beeshyams. Here is a way to do what I wanted. This app allows to parse chosen content from any web page and use it as a widget. In order to have a Spreadsheets document as a web page one can publish it (File → Publish to the web...). The cells of interest can be linked from another page of this document (or even from another document) using ...


3

A great app for that is Automate. I've used it with great success. There are a few plugins that exist; you may or may not need them The main app is here Based on your use case, you may want this, this and maybe this extensions but it all depends on how you use the main app


3

The best one I've ever come across is Tasker. It isn't necessarily coding but you do get to script your tasks in a scratch fashion. Although I don't see how it might be different from Automate which is another great choice. Tasks created for tasker can also be download from the internet of which Tasker Wiki is my favourite source.


3

Source-reddit, which references Android documentation to DISABLE the h/w composer: adb shell service call SurfaceFlinger 1008 i32 1 to ENABLE the h/w composer: adb shell service call SurfaceFlinger 1008 i32 0 These need to be run as root and can be in a script or using the Termux Boot app as described in wiki For some reason, this works the opposite way ...


2

Copy a file (-p preserves permissions and ownership): run_program("/sbin/cp", "-p", "/system/framework/file-to-copy.apk", "/system/file-to-copy.apk"); Rename a file (-f forces overwriting the existing file): run_program("/sbin/mv", "-f", "/system/file-to-copy.apk", "/system/renamed-file.apk"); For reference, the syntax for Edify scripts (that's what they'...


2

You might want to take a look at ScriptManager: Manage and execute shell scripts and programs in file system. All executions run over vt100 terminal accepting user input and esc codes (colors, bel, cursor movement ..) Run them at boot-up and/or on network status change possibility. Schedule at selected time. (cron jobs) Alternatively, Tasker can be ...


2

Adding extensions will solve this type of requirements. But Chrome for android does not support any extensions yet. Look at the Chrome for Android FAQ Or else you can use Dolphin Browser to achieve this. It supports extensions. If you are willing to use Dolphin Browser instead of Chrome, use this Auto Reload Extension. You can set time intervals in it.


2

In addition to the other answer with Tasker ("You could do that using e.g. Tasker, the mighty automation tool:"), here a little Task (description export) with randomizing the MAC: TestMacChanger (130) A1: Variable Set [ Name:%count To:0 Do Maths:On Append:Off ] <randomstart> A2: Variable Randomize [ Name:%random Min:0 Max:15 ] A3: ...


2

Wrong syntax :) adb shell "mount -o rw,remount /system" would do in your case (i.e. passing the command you want to run on the device to adb shell in double-quotes; the "exit" is not needed here as it is "implied"), provided your device's ADB daemon runs in root mode. You can even run multiple commands at once this way, e.g.: adb shell "mount -o rw,...


2

Matthew already pointed to tasker for this task (uh) – an app I already use for years. So let me add the steps to achieve this. Obviously, a pre-condition is the device is rooted – but the su command in the question tells me it is. So here we go: Condition: State › Net › WiFi Connected As parameter, include the SSID of your WiFi network, so it doesn't fire ...


2

In your script you forgot # , and what is more the command to delete is not delete(as you wrote) but rm, along with at least one option: -r for recursive -f for force -v for verbose so try For a single file #!/system/bin/sh rm /path/to/file/filename.extension For a group of files @ location by extension with wildcard: #!/system/bin/sh rm /path/to/...


2

The Reason for this failure is that Android blocked chroot for som reason. Like Death Mask Salesman pointed out, it is possible to get information about the command type via type commandName e.g. in this case type chroot. To solve the tmp-mksh: chroot: not found-error it is only required to install BusyBox.


Only top voted, non community-wiki answers of a minimum length are eligible