ADB enhanced Putty (replacement for "adb shell" command)

Search This thread

sztupy

Inactive Recognized Developer
Dec 21, 2008
1,061
877
London
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 "0012transport-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:
- 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)

DL and source: http://github.com/sztupy/adbputty/downloads

Screenshot:
attachment.php
 

Attachments

  • putty.jpg
    putty.jpg
    34.4 KB · Views: 47,117
Last edited:

Namuna

Senior Member
Jan 11, 2010
518
99
New York
Thanks for this sztupy! I had scripted out connecting to my N1 via putty, but lost the scripts. :(

I just tried connecting using your tweaked putty, but got an error. Here're a couple screenshots to show how I tried to connect and the issue I had.
 

Attachments

  • puttySettings.gif
    puttySettings.gif
    24.2 KB · Views: 5,964
  • gethost.gif
    gethost.gif
    10.8 KB · Views: 5,207

sztupy

Inactive Recognized Developer
Dec 21, 2008
1,061
877
London
sztupy.hu
Thanks for this sztupy! I had scripted out connecting to my N1 via putty, but lost the scripts. :(

I just tried connecting using your tweaked putty, but got an error. Here're a couple screenshots to show how I tried to connect and the issue I had.

The only place where it uses gethostbyname is while querying "localhost". I don't know why this fails. (maybe IPv6 related(?)...) I'll replace it to actually use "127.0.0.1"...
 

goulloux

Senior Member
Dec 18, 2007
71
4
Hi there, just go an LG Optimus 2X, and I'm starting to play with it.
But as my linux skill is almost inexistant I do have a hard time :)
So I wanted to use your alternate putty, mainly for tab-completion, but it doesn't work.
Putty is working, but "tab" is just tabing ...
Read that's a server functionality ==> does it mean that I need to install something on my phone ?

Thx for your time
 

sztupy

Inactive Recognized Developer
Dec 21, 2008
1,061
877
London
sztupy.hu
Hi there, just go an LG Optimus 2X, and I'm starting to play with it.
But as my linux skill is almost inexistant I do have a hard time :)
So I wanted to use your alternate putty, mainly for tab-completion, but it doesn't work.
Putty is working, but "tab" is just tabing ...
Read that's a server functionality ==> does it mean that I need to install something on my phone ?

Thx for your time

To have auto complete you need to have an auto-complete enabled shell on the phone. The default "sh" shell is very minimal (as usual phone users won't use it), so you need another one. Busybox's "sh" is actually "ash" which has all of the features you need. So to use this feature you have to have busybox installed (which is usually there if you have rooted your phone, or can be installed from market)

If you have busybox installed, then you have to run it's sh with "busybox sh" or "busybox ash". You'll get a new prompt with the new features.
 

notageek1212

New member
Sep 14, 2011
1
0
Putty replacement

Hi there,
I don't know how relevant my post is in the context of this thread but I just wanted to let everyone know that I came across a new free terminal "ClearTerminal" which seems to be good.
You can try this one out if you need a replacement for putty or any other terminal.
It's available at clearconnex.com/content/clearterminal

Have a good time :)
 

Euclid's Brother

Senior Member
May 3, 2011
950
262
Dallas, TX
www.interphaze.com
I'm using the modified PuTTY above, which works great if there is only one device connected. Is there a way to specify a device# if you have more than one device connected?

Thanks,

For anyone interested in using this when multiple devices are connected, here's sztupy's response..

sztupy said:
Yeah it's possible, and if you know the ID's of the devices you can already do it. The "transport-usb" seciotn actually means that connect to the only available usb device. If there are more than one, you have to specify the actual one. Here is the command list: http://lxr.e2g.org/source/system/core/adb/SERVICES.TXT

According to it you have to use the "transport:<serial-number>" command

Thanks sztupy!
 

DownloaderZ

Senior Member
Jun 10, 2008
258
11
ATL
mulţumesc!!

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 "0012transport-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:
- 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)

DL and source: http://github.com/sztupy/adbputty/downloads

Screenshot:
attachment.php
 

Kytrix

Member
Jun 14, 2010
39
5
Command history ?

Very nice tips and patch to putty !

It works great exept on one point :
I can't use command history, with commands I use before login (so during a previous login)
If I connect with adb shell with up arrow I see last commands I send. Not with putty-adb (neither with normal putty with manual 'login')

Can you access to your command history ?

Kytrix.
 
Last edited:

sztupy

Inactive Recognized Developer
Dec 21, 2008
1,061
877
London
sztupy.hu
Very nice tips and patch to putty !

It works great exept on one point :
I can't use command history, with commands I use before login (so during a previous login)
If I connect with adb shell with up arrow I see last commands I send. Not with putty-adb (neither with normal putty with manual 'login')

Can you access to your command history ?

Kytrix.

That's because the sh on your phone does not support saving of command history. I don't know whether there exists an appropriate sh version for Android that supports this feature.
 

TonyApuzzo

Senior Member
Aug 20, 2010
70
27
Now that I have the ADB enhanced Putty, I am annoyed that I have to manually launch the ADB server, so I wrote a batch file to start the ADB server daemon and then lauch Putty directly connected to the Android device. As described earlier, if you want to connect to a specific device, then you'll need to create and connect to a session that explicitly refers to the device ID. In my case I rarely have more than one Android device plugged in at a time, so the following batch file works for me. The session I'm connecting to is named "Android" which is why the command line for Putty uses @Android. If you had multiple connections, you could make this into a parameter and then invoke the shortcut with an argument then you could have a "Tablet" and a "Phone" shortcut. The script will wait until your device is found before launching Putty, so you can run the script and then plug in your phone later if it happens to be unplugged.

RUN-ADB-PUTTY.BAT
Code:
@echo off
cmd /C adb wait-for-device
start "PuTTY" /B "C:\Program Files (x86)\PuTTY\adbputty.exe" @Android

Once I created this file, I then made a shortcut to the script and placed it in my Windows 7 start menu.
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 38
    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 "0012transport-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:
    - 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)

    DL and source: http://github.com/sztupy/adbputty/downloads

    Screenshot:
    attachment.php
    5
    Now that I have the ADB enhanced Putty, I am annoyed that I have to manually launch the ADB server, so I wrote a batch file to start the ADB server daemon and then lauch Putty directly connected to the Android device. As described earlier, if you want to connect to a specific device, then you'll need to create and connect to a session that explicitly refers to the device ID. In my case I rarely have more than one Android device plugged in at a time, so the following batch file works for me. The session I'm connecting to is named "Android" which is why the command line for Putty uses @Android. If you had multiple connections, you could make this into a parameter and then invoke the shortcut with an argument then you could have a "Tablet" and a "Phone" shortcut. The script will wait until your device is found before launching Putty, so you can run the script and then plug in your phone later if it happens to be unplugged.

    RUN-ADB-PUTTY.BAT
    Code:
    @echo off
    cmd /C adb wait-for-device
    start "PuTTY" /B "C:\Program Files (x86)\PuTTY\adbputty.exe" @Android

    Once I created this file, I then made a shortcut to the script and placed it in my Windows 7 start menu.
    1
    Hi, I like to use the command busybox for all commands.

    Is there a way we can automate it rather than typing it every time.

    eg: instead of typing ls /sdcard/
    preferred command is busybox ls sdcard

    Hence make [email protected]:/ # automatically use the prefix "busybox " before commands

    I can think two solutions, one is modify PATH so xbin goes first (assuming that in xbin you have all the symbolic links to busybox [ command]). The other option is define alias for the commands you use most, for example ls alias for busybox ls -la

    Br

    Sent from my C6603 using Tapatalk 4 Beta
    1
    Up-to-date putty with adb support

    Thanks to the OP for the patched putty but I could not make it work with multiple devices (all blame is on me indeed).
    But Here is another version of putty with adb support based on the latest version. Works flawlessly when multiple devices are connected (inl. tcp connections).