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

Search This thread

sztupy

Inactive Recognized Developer
Dec 21, 2008
1,061
877
Edinburgh
sztupy.hu
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
 
Last edited:

lownoise

Senior Member
Sep 3, 2010
206
127
Thanks

Great job:cool:

Love to use putty.
If this do what your say it's good buy adb shell!!
 

ykkfive

Inactive Recognized Developer
Jul 25, 2010
3,223
3,018
ykkfive.blogspot.com
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
 
Last edited:

hardcore

Senior Member
Sep 12, 2006
3,435
7,992
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.
 

sztupy

Inactive Recognized Developer
Dec 21, 2008
1,061
877
Edinburgh
sztupy.hu
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=pl...T;hb=f41986bbc79055a4feed7266cac5c1b540296daf

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)
 

sztupy

Inactive Recognized Developer
Dec 21, 2008
1,061
877
Edinburgh
sztupy.hu
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.
 
  • Like
Reactions: Rc-Blob

neldar

Retired Recognized Developer
Jul 4, 2010
569
363
twitter.com
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.
 
Last edited:

ykkfive

Inactive Recognized Developer
Jul 25, 2010
3,223
3,018
ykkfive.blogspot.com
The complete specification is here: http://android.git.kernel.org/?p=pl...T;hb=f41986bbc79055a4feed7266cac5c1b540296daf

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
 

ykkfive

Inactive Recognized Developer
Jul 25, 2010
3,223
3,018
ykkfive.blogspot.com
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
 

mathieumeuh

Senior Member
Aug 8, 2010
112
12
Paris
matfrapp.blogspot.com
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
 

jodue

Senior Member
Dec 15, 2009
453
37
vienna
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 :D ... i can provide the binary+explanation if anybody is interested.
 

jodue

Senior Member
Dec 15, 2009
453
37
vienna
I'm very interested in that !

Sent from my GT-I9000 using XDA App

here is the explanation how to set it up (cyanogenmod wiki):
http://wiki.cyanogenmod.com/index.php?title=Howto:_Connect_to_Device_with_SSH

basically you have to create the keys on your pc and copy them onto the device. then you can connect via key-auth. if you want dropbear to autostart @boot you could add it to playlogos1 ...

and here are the binary's you need (including the missing dropbear-keygen) and a bash binary:
http://www.multiupload.com/B0L9FDQHPB

bash is optional of course but it's very nice to have tab-completion and the other improvements bash offers over sh. to replace sh with bash do the following:

Code:
cp bash /system/bin/
chmod 0755 /system/bin/bash
mv /system/bin/sh /system/bin/sh_OLD
ln -s /system/bin/bash /system/bin/sh

the chmod is really important. i forgot it once and then was unable to get shell access even over adb. was a pain in the ass to fix it again :D
 

sztupy

Inactive Recognized Developer
Dec 21, 2008
1,061
877
Edinburgh
sztupy.hu
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 :D ... i can provide the binary+explanation if anybody is interested.

You seem to miss the point of this development. First, your method is mentioned as one of the possible workarounds in the first post. Second you need to have some kind of telnet/ssh server running on the phone, which you don't need, if using adb.

Meanwhile you don't even need a rooted phone or busybox or anything to get this thing working.

The main problem with adb shell under windows, that it uses the standard cmd.exe to run, and uses the standard cmd.exe's "readline" support, which only supports the up and down keys for history (and even that it only supports that within one session).

Putty is mainly the only good (xterm compatible) terminal emulator for windows (msys's or cygwin's rxvt is good too, but "adb shell" was programmed in a way that makes it kinda useless under rxvt too). There are two ways to fix this. One is to make adb.exe more comptible with rxvt, the other is to skip adb.exe entirelly and communicate with the adb server without it. This project utilises the latter.
 

sargasso

Senior Member
Sep 7, 2010
174
22
This is the reason I recommend a faulty device: without the problems with the SGS the developments would go much slower :D Thank you for this putty, i have it connecting to the bash. Color coding and keys work perfectly.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 23
    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
    1
    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.
    1
    how can i set busybox as default shell to i have all commands inside busybox without to write everytime busybox command(ls,df,cat,etc...)

    ps. i have doc.7.6.2 rom
    thx

    su
    busybox rm -Rf /system/bin/sh
    busybox ln -s /system/xbin/busybox /system/bin/sh
    rm -Rf /system/bin/ls /system/bin/df /system/bin/cat /system/bin/du
    busybox --install -s /system/bin
    1
    Wireless ADB? No way! Count me in! I'll test for free! ROFLMAO!

    This is a request for ADB enhanced putty to work with ADBWireless app. ADBWireless itself is not new if that is what excited you ;)

    https://market.android.com/details?id=siir.es.adbWireless&hl=en
    1
    Any update to use this with ADBWireless? Thanks in advance.

    It already works. You have to connect to your device using a cmd shell:

    adb connect 192.168.1.xxx:5555

    then use "transport-any" inside adbputty