ADB on Windows: output to text file? - General Questions and Answers

Hi,
I wonder how to output the text from adb on Windows to a textfile. I tried:
adb list packages > test.txt //gives the error: Read-only file system
when I enter a path that exists and has user write access, I get the same error, like:
adb list packages > c:\\temp\\test.txt //it won't take single backslashes at all
What is the correct way to redirect the output of adb to a text file?

Related

[Resolved] [Q] Setting Up ADB/USB Drivers for Android Devices in Ubuntu maverick 10.10?

OK so I tried these instruciton for Lucid on Maverick. I would post the link but I can't cuz I'm a newbie.
Download the latest Android SDK from Google: Android SDK
Extract the TGZ file to your home/user directory
NOTE: User would be your username
On your phone, click Settings > Applications > Development and make sure USB Debugging is on.
Login as root and create this file: /etc/udev/rules.d/##-android.rules
NOTE: In the above file replace ## with the number 50 if you are running Gusty/Hardy/Dapper (50-android.rules) or with the number 70 if you are running Karmic Koala/Lucid Lynx(70-android.rules)
Or simply type in terminal sudo gedit /etc/udev/rules.d/##-android.rules then enter your password
The file should read:
For Gusty/Hardy: SUBSYSTEM==”usb”, SYSFS{idVendor}==”0bb4″, MODE=”0666″
For Dapper: SUBSYSTEM==”usb_device”, SYSFS{idVendor}==”0bb4″, MODE=”0666″
For Karmic Koala: SUBSYSTEM==”usb”, SYSFS{idVendor}==”0bb4″, MODE=”0666″
For Lucid: SUBSYSTEM==”usb”, SYSFS{idVendor}==”0bb4″, MODE=”0666″
NOTE: In the above lines the code ”0bb4″ refers to a HTC device. If your phone is from a different manufacturer, replace the code with the appropriate from the table below.
Execute: sudo chmod a+rx /etc/udev/rules.d/70-android.rules
Reboot
To run ADB you need to add an environment variable to your bashrc file:
Open a terminal window and type: sudo gedit .bashrc
Add the following line at the end: export PATH=${PATH}:~/home/user/android-sdk-linux_86/tools
Save and close
You should be ready to go, type adb devices in a terminal window with your phone plugged in.
If you see a serial number pop up that means you are done. Should look something like this:
List of devices attached
HT99PHF02521 device
If for some reasons when running adb devices gives you a “no permissions” error, try typing the following in terminal
adb kill-server
adb start-server
USB Vendor IDs
MANUFACTURER USB VENDOR ID
Acer 0502
Dell 413c
Foxconn 0489
Garmin-Asus 091E
HTC 0bb4
Huawei 12d1
Kyocera 0482
LG 1004
Motorola 22b8
Nvidia 0955
Pantech 10A9
Samsung 04e8
Sharp 04dd
Sony Ericsson 0fce
ZTE 19D2
Common ADB Commands
- Lists which devices are currently attached to your computer
adb devices
- Drops you into a basic linux command shell on your phone with no parameters, or lets you run commands directly
adb shell
- Lets you install an Android application on your phone
adb install
- Remounts your system in write mode – this lets you alter system files on your phone using ADB
adb remount
- Rets you upload files to your phones filesystem
adb push
- Lets you download files off your phones filesystem
adb pull
- Starts dumping debugging information from your handset to the console – useful for debugging your apps
adb logcat
Now, as for the credits, I took TheUnlockr “How To” for Windows as a base for this guide.
Click to expand...
Click to collapse
But it doesn't work in maverick. Please help. Because I really want to overlock my phone.
Also keep in mind I'm fairly new to Linux so be easy on the newbie.
Thanks guys.
49 views and no responds? Please help I'm desperate here.
So did post this in the wrong section? This silent treatment is killing me. lol
in terminal type:
$ sudo -i
$ gedit .bashrc
insert the same line at the end: export PATH=${PATH}:~/home/user/android-sdk-linux_86/tools
$ exit
$ sudo -i
$ adb kill-server
$ adb start-server
$ adb devices
benholiio said:
in terminal type:
$ sudo -i
$ gedit .bashrc
insert the same line at the end: export PATH=${PATH}:~/home/user/android-sdk-linux_86/tools
$ exit
$ sudo -i
$ adb kill-server
$ adb start-server
$ adb devices
Click to expand...
Click to collapse
Dude this is for adb, not for recognizing the USB...
My phone is HTC Desire and I am still figuring out why it doesnt work on 10.10 with all the rules...
hungrysquid said:
Dude this is for adb, not for recognizing the USB...
My phone is HTC Desire and I am still figuring out why it doesnt work on 10.10 with all the rules...
Click to expand...
Click to collapse
I'm assuming thisisspeedy got to the same stage i did: USB connects, i can access files through maverick, however adb won't detect the device to allow push/pull/shell.
simply elevating to root & editing the bash script on maverick solves the problem.
I have my Galaxy S connected to Maverick via USB, and i can run all ADB functions.
It should work for HTC using the correct code. If you have a problem with Ubuntu detecting your device on USB when you've set USB to mount on Android, PM me and I'll see if i can help.
Could someone post a link for the Lucid dirs? Thanks.
Sent from my T-Mobile G2 using XDA App
Thanks for everyone responses.
I figured it out thanks to this.
[QUOTEThe Android Debug Bridge (adb) is a tool lets you manage the state of an emulator instance or Android-powered device.
I was trying to run it for the first time on my ubuntu 9.10 box and I kept getting this error:
desktop:~/dev/Android/android-sdk-linux/tools$ adb
No command 'adb' found, did you mean:
Command 'cdb' from package 'tinycdb' (main)
Command 'gdb' from package 'gdb' (main)
Command 'aub' from package 'aub' (universe)
Command 'dab' from package 'bsdgames' (universe)
Command 'mdb' from package 'mono-debugger' (universe)
Command 'arb' from package 'arb' (multiverse)
Command 'tdb' from package 'tads2-dev' (multiverse)
Command 'pdb' from package 'python' (main)
Command 'jdb' from package 'openjdk-6-jdk' (main)
Command 'jdb' from package 'sun-java6-jdk' (multiverse)
Command 'ab' from package 'apache2-utils' (main)
adb: command not found
What was I doing wrong?
A quick google search shows me the error of my ways.. I haven't added my Android SDK tools directory to my system path!
It should go something like this...
open a terminal window and type:
$ echo $PATH
---(should return the directories associated with $PATH)
$ export PATH=$PATH:/home/YOUR-USERNAME/sdk/tools
---(replace with path to your tools directory, you may need to add 'sudo' to the beginning of this cmd)
$ echo $PATH
---(you should now see your tools directory added to the end of the $PATH variable)
$ adb devices
---(now adb should do something, if nothing else at least error, no devices)
And now I get:
List of devices attached
emulator-5554 device
Sweet Success!
p.s. Adding to the system path in Windows is along the lines of :
right-click '(My) Computer'
Select 'Properties'
Go to 'Advanced' or whatever tab you find 'Environment Variables'
Select 'Path' then 'Edit' and add your new path in.][/QUOTE]
adb trouble
Hi i am runing on Ubuntu Maverick with device Huawei U8110 on Celestial Teapot 4 ROM
java jdk ver6
installed Android SDK and tools in the home folder
i edit the rules file 99-android.rules to SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", SYMLINK+="android_adb", MODE="0666" GROUP="plugdev"
saved and added the file permisions
restart the udev
Connected the Phone put the debug mode on
kill the adb then started
And Then Run The comand
[email protected]:/home/android-sdk-linux_x86/platform-tools# ./adb devices
List of devices attached
There is nothing in the list....?
HELP!? Please......
I use it for Marveric.
vim /etc/udev/rules.d/70-android.rules
# IS01
SUBSYSTEM=="usb",ATTRS{idVendor}=="04dd",ATTRS{idProduct}=="04dd",MODE="0666",OWNER="root"
# GalaxyS
SUBSYSTEM=="usb",ATTRS{idVendor}=="04e8",ATTRS{idProduct}=="681c",MODE="0666",OWNER="root"
# bravo
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
add like a above. then
/etc/init.d/udev restart
Good luck!
thisisspeedy said:
I figured it out thanks to this.
[QUOTEThe Android Debug Bridge (adb) is a tool lets you manage the state of an emulator instance or Android-powered device.
I was trying to run it for the first time on my ubuntu 9.10 box and I kept getting this error:
desktop:~/dev/Android/android-sdk-linux/tools$ adb
No command 'adb' found, did you mean:
Command 'cdb' from package 'tinycdb' (main)
Command 'gdb' from package 'gdb' (main)
Command 'aub' from package 'aub' (universe)
Command 'dab' from package 'bsdgames' (universe)
Command 'mdb' from package 'mono-debugger' (universe)
Command 'arb' from package 'arb' (multiverse)
Command 'tdb' from package 'tads2-dev' (multiverse)
Command 'pdb' from package 'python' (main)
Command 'jdb' from package 'openjdk-6-jdk' (main)
Command 'jdb' from package 'sun-java6-jdk' (multiverse)
Command 'ab' from package 'apache2-utils' (main)
adb: command not found
What was I doing wrong?
A quick google search shows me the error of my ways.. I haven't added my Android SDK tools directory to my system path!
It should go something like this...
open a terminal window and type:
$ echo $PATH
---(should return the directories associated with $PATH)
$ export PATH=$PATH:/home/YOUR-USERNAME/sdk/tools
---(replace with path to your tools directory, you may need to add 'sudo' to the beginning of this cmd)
$ echo $PATH
---(you should now see your tools directory added to the end of the $PATH variable)
$ adb devices
---(now adb should do something, if nothing else at least error, no devices)
And now I get:
List of devices attached
emulator-5554 device
Sweet Success!
p.s. Adding to the system path in Windows is along the lines of :
right-click '(My) Computer'
Select 'Properties'
Go to 'Advanced' or whatever tab you find 'Environment Variables'
Select 'Path' then 'Edit' and add your new path in.]
Click to expand...
Click to collapse
============================================================
THANK YOU!! (I did hit 'THANKS' as well)...
You pointed me in the right direction with Ubuntu 10.04.
The only change was with SDK..the 'adb' has moved to $ ~/platform-tools/
By the way folks, when you install SDK, it would be wise to do all the updates, otherwise the platform-tools folder won't be an option....:cyclops:
"The order has been restored.."

ADB not working in Ubuntu10.10

whenever i use adb in ubuntu it just says this:
Code:
[email protected]:~# cd /sdk/platform-tools
[email protected]:/sdk/platform-tools# adb devices
No command 'adb' found, did you mean:
Command 'cdb' from package 'tinycdb' (main)
Command 'gdb' from package 'gdb' (main)
Command 'dab' from package 'bsdgames' (universe)
Command 'zdb' from package 'zfs-fuse' (universe)
Command 'mdb' from package 'mono-debugger' (universe)
Command 'tdb' from package 'tads2-dev' (multiverse)
Command 'pdb' from package 'python' (main)
Command 'jdb' from package 'openjdk-6-jdk' (main)
Command 'ab' from package 'apache2-utils' (main)
Command 'ad' from package 'netatalk' (universe)
adb: command not found
doesnt make sense.. works in windows but im tired of rebooting to use adb
any ideas?
Make sure adb in is your PATH: echo $PATH
If not, add it: export PATH=$PATH:/path/to/sdk/platform-tools
ikon8 said:
Make sure adb in is your PATH: echo $PATH
If not, add it: export PATH=$PATH:/path/to/sdk/platform-tools
Click to expand...
Click to collapse
I think you mean in your bash file. Go into your home folder and hit control-h. It should show hidden files. Open your bash and put the above-mentioned.
If you don't want to go that far you can always navigate to that directory and punch in the commands.
Sent from my ADR6400L using Tapatalk
thanks for the replies guys but ive already done that as well..ugh this is frustrating
You run an executable binary with a ./ before it in linux.
./adb devices
Like that.
But it's really best to add the directory to your path, so you can run adb from any directory easily.
Add this line to your .bashrc file (which is in your home directory) at the end:
export PATH=/sdk/platform-tools:$PATH
Then close and open a new terminal. Then you should be able to run adb without the ./ from any directory.
If that still doesn't work, type "echo $PATH" and make sure it shows the directory there. If not, you did something wrong saving that line in your .bashrc file, or it's not being loaded properly.
Nikolai2.1 said:
whenever i use adb in ubuntu it just says this:
Code:
[email protected]:~# cd /sdk/platform-tools
[email protected]:/sdk/platform-tools# adb devices
No command 'adb' found, did you mean:
Command 'cdb' from package 'tinycdb' (main)
Command 'gdb' from package 'gdb' (main)
Command 'dab' from package 'bsdgames' (universe)
Command 'zdb' from package 'zfs-fuse' (universe)
Command 'mdb' from package 'mono-debugger' (universe)
Command 'tdb' from package 'tads2-dev' (multiverse)
Command 'pdb' from package 'python' (main)
Command 'jdb' from package 'openjdk-6-jdk' (main)
Command 'ab' from package 'apache2-utils' (main)
Command 'ad' from package 'netatalk' (universe)
adb: command not found
doesnt make sense.. works in windows but im tired of rebooting to use adb
any ideas?
Click to expand...
Click to collapse
I know exactly what this is. Get out of hard root and stay in your regular home folder. There are two things that will make this simple for you. 1. take the adb executable and place it in your users bin. so that would be something like /usr/bin...once again make sure you are in nautilus as the regular user and not root! 2. Now go back into your terminal and invoke it by typing sudo adb start-server...then sudo adb devices...the key thing here is that ubuntu's permissions are a bit screwy so you have to use adb in this manner. once again sudo everthing ("sudo adb" etc.)...do not become hard root in ubuntu (sudo su)
EDIT: btw if you use this method you will not have to worry about paths as long as it's in your user bin...you dont have to ./adb devices either if you do it this way
Javis
GrdLock said:
You run an executable binary with a ./ before it in linux.
./adb devices
Like that.
But it's really best to add the directory to your path, so you can run adb from any directory easily.
Add this line to your .bashrc file (which is in your home directory) at the end:
export PATH=/sdk/platform-tools:$PATH
Then close and open a new terminal. Then you should be able to run adb without the ./ from any directory.
If that still doesn't work, type "echo $PATH" and make sure it shows the directory there. If not, you did something wrong saving that line in your .bashrc file, or it's not being loaded properly.
Click to expand...
Click to collapse
trendsetter37 said:
I know exactly what this is. Get out of hard root and stay in your regular home folder. There are two things that will make this simple for you. 1. take the adb executable and place it in your users bin. so that would be something like /usr/bin...once again make sure you are in nautilus as the regular user and not root! 2. Now go back into your terminal and invoke it by typing sudo adb start-server...then sudo adb devices...the key thing here is that ubuntu's permissions are a bit screwy so you have to use adb in this manner. once again sudo everthing ("sudo adb" etc.)...do not become hard root in ubuntu (sudo su)
EDIT: btw if you use this method you will not have to worry about paths as long as it's in your user bin...you dont have to ./adb devices either if you do it this way
Javis
Click to expand...
Click to collapse
Thank you both for the advice! Both things worked very well and i appreciate the advise!

How to pull mmcblk0 or any partition directly to pc?

I have tried following command on ADB to extract partition, but failed.
source:fciotti.com/2017/02/26/clone-android-memory
Code:
chmod +r /dev/block/mmcblk0
returns
Code:
Bad mode
Code:
adb pull /dev/block/mmcblk0 "mmc.img"
returns
Code:
remote permission denied
I have post a question on stack exchange, and found a command working but failed after dumping 4gb on sdcard (not directly to pc) because of file system.
source:android.stackexchange.com/questions/185433/problem-with-coping-mmcblk0-to-pc?noredirect=1#
Code:
adb exec-out "su -c 'cat /dev/block/mmcblk0'" > mmc.img
but it create a 0kb img file.
Please anyone help.

Problems with ADB push and --sync+

I'm attempting to use adb's push command on Windows 10 in order to transfer files from my PC to my Oneplus 9 Pro. I installed adb by following the instructions here. When I attempt to do the file transfer, I receive a large number of error message for some of the files, that all look like this:
Code:
E:\>adb push Music /sdcard/Music
cannot lstat 'Music/??????': No such file or directory
cannot lstat 'Music/????? ??....flac': No such file or directory
cannot lstat 'Music/????? ????????? - ??????? ?????? (2011)': No such file or directory
cannot lstat 'Music/????????? ??????? ??? - 1990 - ??? ?? ??????': No such file or directory
cannot lstat 'Music/???? ? ????????.mp3': No such file or directory
cannot lstat 'Music/??? ?????? ?????.flac': No such file or directory
cannot lstat 'Music/??????? ????.mp3': No such file or directory
cannot lstat 'Music/??????': No such file or directory
cannot lstat 'Music/?????? ????.flac': No such file or directory
cannot lstat 'Music/?? ?????? ???? ??? ? ? ????? ?? ??????.mp3': No such file or directory
cannot lstat 'Music/??, ???????.mp3': No such file or directory
I have used adb with these exact same files before, when I was still running Manjaro, with no issues or error messages such as these, so I'm fairly confident the issue is not with the files themselves. Even more bizarrely, when I attempt to use the --sync command, it doesn't even recognize it as a command:
Code:
E:\>adb push --sync Music /sdcard/Music
cannot stat '--sync': No such file or directory
I've attempted to uninstall and reinstall adb, but the issues persists in spite of that. What possible solutions are there to this?
Youn have to name the fullpathname of folder Music on PC.
xXx yYy said:
Youn have to name the fullpathname of folder Music on PC.
Click to expand...
Click to collapse
I do have the full path name, Music folder is located in E:\Music and I open Command Prompt to E:\ drive. I also know it's the correct path name because some of the files do transfer, but a large number have errors as discussed above.

ADB command to insert SQL data

I'm trying to give an application root access in Magisk.
If I run these commands manually this works:
Code:
adb shell
su
sqlite3 /data/adb/magisk.db "INSERT INTO policies (uid,policy,until,logging,notification) VALUES(12345,2,0,1,1)"
What I am trying to do though is do it through a batch script as a single line. I tried different variations of this:
Code:
adb shell "su -c 'sqlite3 /data/adb/magisk.db 'INSERT INTO policies (uid,policy,until,logging,notification);VALUES(12345,2,0,1,1);''"
adb shell "su -c 'sqlite3 /data/adb/magisk.db 'INSERT INTO policies uid,policy,until,logging,notification;VALUES 12345,2,0,1,1;''"
adb shell "su -c 'sqlite3 /data/adb/magisk.db 'INSERT INTO policies VALUES 12345,2,0,1,1;''"
I either get an error telling me "Error: incomplete input", or "/system/bin/sh: syntax error: unexpected '('"
Does anyone have any thoughts? I'm sure it's just a syntax issue, but I'm not sure what else to try.
Thanks in advance.
In the 2nd code example the quotes used are wrong set: you always must alternate double quote and single quote, means the term
'INSERT INTO policies VALUES 12345,2,0,1,1;'
must get written as
"INSERT INTO policies VALUES 12345,2,0,1,1;"
BTW:
Never run several adb shell one after one: it always opens internally a shell window what really doesn't make sense.
Thank you, I'll give your suggestion a try.
Regarding the adb shell; if I do have multiple ADB shell commands to send, then what would be the proper way to do that?
What I am trying to accomplish is writing a batch script in windows that will automate several tasks for me after a factory reset.
I perform several application installs, disable several applications I don't need,
try to add permissions to apps through ADB, and also try to add root permissions like in my example above.
If there is a better way of sending multiple commands like that, could you show an example?
Quick follow up question...
Is there a way to update permission flags to USER_SET?
I tried:
Code:
adb shell pm clear-permission-flags com.name.app android.permission.READ_EXTERNAL_STORAGE user-set
and
Code:
adb shell pm set-permission-flags com.name.app android.permission.READ_EXTERNAL_STORAGE user-set
both gave me an error that the command is unknown. Is there another way? I am trying to set the USER_SET flag for android.permission.READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE

Categories

Resources