I have an android 4.2 phone on which I wish to run the following script:
su
setprop service.adb.tcp.port 5555
stop adbd
start adbd
If I put it into and .sh file, and have the SManager app to run it, it does nothing, no error nothing, just get back the console. I allow root access for the app.
If I manually type it into Terminal Emulator, then it works.
How can I run .sh files easily (without much typing) other then SManager, as its obviously not working.
Thank you
All my scripts was ctrl c ctrl v to sh files.
Some windows spec char went into the script, and it did nothing.
As soon as i typed the whole thing in on touchkeyboard,
AND allowed Root run within SManager (it was not enough to start it as rooted only),
it came alive.
Thanks!
Related
Since Oreo there is this fancy locksettings command, that allows you to change the screenlock from adb shell. Now, if I try to run it on my PC everything is working. On my handheld the command will just get an "Aborted." back. Why is that and how can I run the locksettings command from my device?
here is the code for the locksettings command, maybe you can already tell by that:
# Script to start "locksettings" on the device
#
base=/system
export CLASSPATH=$base/framework/locksettings.jar
exec app_process $base/bin com.android.commands.locksettings.LockSettingsCmd "$#"
Download QUTE, a command panel. Start from the first command click and run it. About 10 to 15 commands ran will give enough control over the system. Only because most of the commands are going to fail, unable to run. Then the terminal will suggest you to STACK, for the command code to lock setting. Copy the code and paste it in the terminal. For there your settings should be locked.
When I put this line in my test app,
Runtime.getRuntime().exec("uiautomator dump"), no .xml file was dumped. I am pretty sure I checked the correct location.
I tried to debug my app by putting a break point. When it reaches the break point, I adb shell on terminal to get into the device, and then manually run uiautomator dump from terminal, then it says killed, no .xml file was produced either.
adb shell uiautomator dump only produces .xml file when I killed my app, and run this command from terminal.
Is this a sort of permission or accessibility problem?
You can't use adb shell uiautomator dump while a test is running.
You can call UiDevice.dumpWindowHierarchy(..) from inside your test instead.
I have a rooted Android device and I need to pull everything to pc.
First try in DDMS File explorer did not work out, it hangs and has to be force closed.
Trying again in powershell with
adb pull /
skips "special files"
is there a way to pull everything including special files?
EDIT: I have tried booting in Engineer mode and Meta mode and I have tried to copy from shell
No success
2 things:
Try booting the phone into FastBoot and then do adb pull. Some of the files might be in use while the phone is running and causing them to be skipped.
I haven't done this personally, but I would try to use adb to get to shell on the phone and copy the files that were skipped.
adb shell
I have an Android phone that has only su binary installed and it works, meaning I can adb shell into the phone and run an 'su' command and I will be root.
When I try to run a command via code, it doesn't seem to work no matter which way I try to run it. I've tried many different variants of the following command.
Runtime.getRuntime().exec("su -c ps");
When I run this command on another rooted phone with a Superuser.apk or SuperSU.apk app installed, I get a dialog asking if I want to allow it to run with root permissions. When the apks are not there, it never asks and the command never works.
I've tried installing the apks on the first phone but they don't seem to do anything. So, as the original question asks --> Is there any way to run the elevated command from within the app without the SU apps installed?
It might be because you need to pass the commands to su as parameters like this:
su -c 'ls -l'
Or you might need to specify the full path to su, but I don't see why it wouldn't work the way you have it:
Runtime.exec("/system/bin/su -c ps")Or maybeRuntime.exec("/system/bin/su -c \'ps\'")
Try checking the output of this command too: System.getenv("PATH")
Another variant could be Runtime.exec("su -c \'ls -s \'")
Make sure you don't forget to escape the single quotes as they are part of the actual String.
Thats the way that I've found works most consistently, and it has also worked on devices that don't have Superuser or SuperSU installed, as those apps only listen for the Broadcast that is sent out when an application tries to run a command as root. #Boardy SuperSU and Superuser intercept the broadcast and so act as a middle man between the app and root privileges, but its not necessary for a rooted device. It IS necessary if you want to have more control over the applications that are running commands as root, but even then it still only limits you to deciding which applications, not which commands, are given root privileges.
Also, you might wanna take a look at RootTools and more specifically, the RootTools.isAccessGiven() command, which requests root privileges for your app.
Source: Launch a script as root through ADB
Not all versions of an 'su' for Android will accept a command to execute from the command line parameters.
Where they do not, you will need to let 'su' launch a privileged shell, obtain its input file descriptor, and pipe command(s) into that. This has been covered numerous times here on Stackoverflow.
I believe you would need to have the SU apps installed as they are what provide the user the question as to whether the app should be allowed to run as root or not.
You should be able to do this.
try :
adb root shell ls -l
I'm trying to deal with some SQLiteDB issues and wanted to use the ABD tool to access my emulators database. When I click on the adb file in the platform-tool file, it opens up but very quickly throws a bunch of text on the window and then closes. Its so fast I can't even tell what it is doing. I tried running as administrator and it didn't change. I'm using Vista if that has anything to do with it.
Any suggestions for how I can even get it to stop from closing so I can enter a command?
You start the command shell (WindowsKey + R, enter cmd in the window that appears and hit Enter.), then use it from there. adb shell is probably the command you need.
C:\> cd \Path\to\platform-tools
C:\Path\to\platform-tools\> adb shell
if you add the path to your environment PATH you don't need to cd there. [This] should be a good example how to do that.
As mentioned by zapl, you need to launch command prompt, add adb directory to path and then running adb commands. You may also be able to pull the trick with DDMS.
In the answer, it was not clear that you have to run a windows cmd.exe terminal program first. Make sure you are in the correct directory, Then start ADB from within this cmd program.
To ensure that windows can find adb.exe ("being in the correct directory), you can either navigate to the location of the adb.exe (usually Platform tools) manually using "cd" command, or update your path statement so that windows can find it regardless of where your cmd.exe prompt is pointing.