• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Help Qpython - Running terminal commands

Kh4zy

Lurker
May 17, 2015
1
0
Hi all.

I have a python script that I got working on my android phone. Its working perfectly, exept i have a adb shell script, that needs to be run with the python script. I usually do this by hooking my phone to the laptop, but to make it smarter, I'll be run entirely on my phone.

The execute command in the python script:
def change_IP():
os.system(r'""C:\Tools\adb\changeip.bat""')

class Eonda(object):

def change_IP():
os.system(r'""C:\Tools\adb\changeip.bat""')
return

What it does that it changes ip by disabling the 3G data and enables it again. The following bat script is here:
@echo off
set PATH="C:\Scripts\android-sdk-windows\platform-tools"
@echo on
@echo Changing IP Adress
@echo off
adb shell "su -c 'svc data disable'"
adb shell "su -c 'sleep 5'"
adb shell "su -c 'svc data enable'"
adb shell "su -c 'sleep 5'"

I suppose I just could remove the adb shell and the echo's but, how can i execute the terminal commands? It would be easiest to just having some sort of script file, like the bat, but as we all know, batch is a DOS file and Android cant read that, so I need to another solution for this :)
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones