FORUMS
Remove All Ads from XDA

[APP] ADB enhanced Putty (replacement for "adb shell" command)

1,061 posts
Thanks Meter: 877
 
Post Reply Email Thread
We all know that running "adb shell" from the command line is pretty crap, and when using a latter busybox version which has coloring support it's ultimately crap. One workaround was usually to start a telnet server on the phone, and use putty to connect to that telnet server. Actually there is a more easier way to do that which also works for non rooted phones.

Actually the Android Debug Bridge has a terminal connection feature (roughly speaking), which will be enabled after you connect to the adb server in "0006shell:" mode. You can actually use the putty to connect to this interface always, by setting the following things:
- Turn off line discipline in settings
- Use RAW mode to connect to localhost:5037
- Enter "0012host:transport-usb" (without quotes)
- Enter "0006shell:" (without quotes)

Now you've got a full fledged connection to your device. The main drawback is that it's tedious to repeat the above all the time, so I've made some modifications to the putty binary that adds a new type of connection, called "Adb"

To use the enhanced putty (via USB):
- Select Adb from the connection type list
- Enter "transport-usb" in the host (or any other connection string, check the adb socket interface documentation if you need something else than connecting via usb)
- Enter 5037 as port, if it's not already set there.
- Connect and enjoy (you might also save this connection, so next time you only have to double-click on the settings)

To use this via wireless adb:
- Connect to wireless adb using a command shell: "adb connect IP:PORT" (substitute ip and port for the real values)
- Enter "transport-any" in the host
- Enter 5037 as port if it's not already set there
- Connect and enjoy

To use this via the android emulator:
- Enter "transport-local" in the host. Everything else is the same

If you have multiple devices (for example multiple devices connected to usb and/or wileressly)
- Enter "transport:serial-number" in the host, where you substitute "serial-number" with the serial of the device you get by using "adb devices". Everything else is the same.

DL and source: http://github.com/sztupy/adbputty/downloads
The Following 23 Users Say Thank You to sztupy For This Useful Post: [ View ] Gift sztupy Ad-Free
 
 
8th October 2010, 08:06 PM |#2  
lownoise's Avatar
Senior Member
Thanks Meter: 119
 
More
Smile Thanks
Great job

Love to use putty.
If this do what your say it's good buy adb shell!!
8th October 2010, 08:09 PM |#3  
Recognized Developer
Thanks Meter: 2,826
 
Donate to Me
More
i am using putty for a long time, and i just tried urs, it looks great but i failed to connect coz i'm connecting to 2 devices....

so how can i add the -s param to specify which phone i'm gonna connect?

thx


EDIT: wow!!! i removed one of my devices and connected to it now!! ctrl-U now works!!!! THANK YOU!!!

EDIT2: quick question. if i use a normal putty, where to type in 0012transport-usb and 0006shell: ? i typed them in the term but it closed after 0006shell
8th October 2010, 09:12 PM |#4  
Senior Member
Thanks Meter: 8,148
 
Donate to Me
More
Thanks. It works, but any idea how to get the up and down arrow keys to work on Putty? They work on the windows adb shell.
9th October 2010, 12:31 AM |#5  
sztupy's Avatar
OP Inactive Recognized Developer
Flag London
Thanks Meter: 877
 
Donate to Me
More
Quote:
Originally Posted by ykk_five

i am using putty for a long time, and i just tried urs, it looks great but i failed to connect coz i'm connecting to 2 devices....

so how can i add the -s param to specify which phone i'm gonna connect?

thx


EDIT: wow!!! i removed one of my devices and connected to it now!! ctrl-U now works!!!! THANK YOU!!!

EDIT2: quick question. if i use a normal putty, where to type in 0012transport-usb and 0006shell: ? i typed them in the term but it closed after 0006shell

The complete specification is here: http://android.git.kernel.org/?p=pla...c5c1b540296daf

This is what you can use:
- transport-any (either usb or local emulator)
- transport-usb (the only usb device)
- transport-local (the only emulator)
- transport:SERIALNUMBER (the concrete device with the appropriate serial number)

so in your case you have to use the latter.


For the second question, you need to ensure that all of the things are present:
- You are using RAW mode (connecting to localhost:5037)
- Line discipline is on "Force OFF" (in the terminal settings dialog)
- You make some pause between writing the two commands
- You don't press enter/backspace or any other key while entering the commands (the easiest way is to write the commands in eg. notepad, copy them, and paste them into putty by pressing ****+RIGHT MOUSE BUTTON)
9th October 2010, 12:43 AM |#6  
sztupy's Avatar
OP Inactive Recognized Developer
Flag London
Thanks Meter: 877
 
Donate to Me
More
Quote:
Originally Posted by hardcore

Thanks. It works, but any idea how to get the up and down arrow keys to work on Putty? They work on the windows adb shell.

The up and down arrow keys were actually handled by cmd.exe, which is non existent in putty. Instead it's now the responsibility of the shell to do the hard work. The included sh in the phone's sotfware (toolbox sh) is mostly useless here, but if you have busybox installed, you might want to run "busybox sh" after connecting (some rooted phones have busybox's sh as default, on them it should work out of the box).

Busybox's sh can not only handle the up and down arrows, but other things like tab completion works too.
The Following User Says Thank You to sztupy For This Useful Post: [ View ] Gift sztupy Ad-Free
9th October 2010, 06:05 AM |#7  
Retired Recognized Developer
Thanks Meter: 363
 
10
More
Quote:
Originally Posted by sztupy

The up and down arrow keys were actually handled by cmd.exe, which is non existent in putty. Instead it's now the responsibility of the shell to do the hard work. The included sh in the phone's sotfware (toolbox sh) is mostly useless here, but if you have busybox installed, you might want to run "busybox sh" after connecting (some rooted phones have busybox's sh as default, on them it should work out of the box).

Busybox's sh can not only handle the up and down arrows, but other things like tab completion works too.

Use the ash.

edit:
Btw, thank you for this adb-putty.
9th October 2010, 07:13 AM |#8  
Recognized Developer
Thanks Meter: 2,826
 
Donate to Me
More
Quote:
Originally Posted by sztupy

The complete specification is here: http://android.git.kernel.org/?p=pla...c5c1b540296daf

This is what you can use:
- transport-any (either usb or local emulator)
- transport-usb (the only usb device)
- transport-local (the only emulator)
- transport:SERIALNUMBER (the concrete device with the appropriate serial number)

so in your case you have to use the latter.


For the second question, you need to ensure that all of the things are present:
- You are using RAW mode (connecting to localhost:5037)
- Line discipline is on "Force OFF" (in the terminal settings dialog)
- You make some pause between writing the two commands
- You don't press enter/backspace or any other key while entering the commands (the easiest way is to write the commands in eg. notepad, copy them, and paste them into putty by pressing ****+RIGHT MOUSE BUTTON)


thx for u reply, but all i got in the log:

=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2010.10.09 13:10:54 =~=~=~=~=~=~=~=~=~=~=~=
0012transport-usb
0006shell:
FAIL0012device offline (x)


with adb turned on and working
9th October 2010, 12:26 PM |#9  
Recognized Developer
Thanks Meter: 2,826
 
Donate to Me
More
Quote:
Originally Posted by sztupy

The up and down arrow keys were actually handled by cmd.exe, which is non existent in putty. Instead it's now the responsibility of the shell to do the hard work. The included sh in the phone's sotfware (toolbox sh) is mostly useless here, but if you have busybox installed, you might want to run "busybox sh" after connecting (some rooted phones have busybox's sh as default, on them it should work out of the box).

Busybox's sh can not only handle the up and down arrows, but other things like tab completion works too.


Yes and it will be great if busybox can handle history like linux
9th October 2010, 12:43 PM |#10  
Senior Member
Flag Paris
Thanks Meter: 12
 
More
ADB over wireless ?
Hi, thanks for your great work

I'm using ADB Wireless
The first step is to connect first with
Code:
adb.exe connect 192.168.6.14:5555
And then the standard procedure

Is it possible for you to include these two phases directly inside Putty ?

So we just have to enter the IP address of the phone and here we go


PS : to disconnect, we have to do
Code:
adb.exe disconnect 192.168.6.14:5555
but that's not an obligation
9th October 2010, 02:40 PM |#11  
jodue's Avatar
Senior Member
Flag vienna
Thanks Meter: 37
 
More
seems to be a windows/putty problem because adb shell works wonderful on ubuntu with the default shell ...

btw. you can also easily get a sshd (dropbear) running. then you can ssh onto the device over wifi ... i can provide the binary+explanation if anybody is interested.
Post Reply Subscribe to Thread

Tags
adb, command line, putty, shell

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes