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 ...


11

Using adb, I believe it is possible: am [start|instrument] am start [-a <action>] [-d ] [-t <mime_type>] [-c <category> [-c <category>] ...] [-e <extra_key> <extra_value> [-e <extra_key> <extra_value> ...] [-n <component>] [-D] [<uri>] am instrument [-e <arg_name> <...


11

Android's shell will support a limited amount of Unix-style shell scripting. It specifically should have a shell at /system/bin/sh that you can use, however: The shell provided with Android has a severely restricted set of commands available to it. If you want to do anything even remotely complex you'll need a busybox install (or another shell). It's ...


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

There are a few Android apps that are able to control other Android apps, and can chain several commands together using their GUI in a similar way to a script, they both have plugins to extend their support to many popular Android apps and functions. Tasker and Locale are probably the most famous of these (see here for some comparison) but there are also ...


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

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

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

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

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 ...


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

Easy peasy: I was using adaway (an app that blocks ads) and somehow its tweaking of my hosts file was not accepted by Python. Yay! :D


3

Android apps aren't binaries. They're .apk's, similar to Java .jar files, and .dex or .odex files when in bytecode form. They're run in the Dalvik virtual machine, again very similar to a Java VM. You can launch an app from a shell as follows: am start -a android.intent.action.MAIN -n <package name>/<activity name> For example, Angry Birds: ...


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.


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 will probably be unable to directly execute scripts from your sdcard. At least without root. Reason is, with most ROMs sdcards are mounted using the noexec flag -- which means, as the term suggests: "no exec from here". Of course, having root you could simply remount the sdcard while removing this option. Why might this option be forced? I'd say for ...


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

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

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

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.


2

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 ...


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