0

Related questions I researched:

How to get Android AVD name from serial number

And we have the following solutions:

(sleep 0.5; echo 'avd name') | telnet 127.0.0.1 5554

I work on 2 OSes: OS X Yosemite, and a Debian VM. Changing the sleep time doesn't really matter.

I start an emulator in each system. The adb devices shows everything correct: emulator-5554 device. Now I am trying to get the name of the running emulator.

Here what happens on OS X:

(sleep 1; echo "avd name") | telnet 127.0.0.1 5554
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Android Console: type 'help' for a list of commands
OK
Connection closed by foreign host.

Here what happens on Debian:

(sleep 1; echo "avd name") | telnet localhost 5554
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Android Console: type 'help' for a list of commands
OK
emu_19_WVGA800
OK
Connection closed by foreign host.

But it fails sometimes, it's not stable at all, sometimes it fails alike with OS X.

In tried also this: {echo open 127.0.0.1 5554; sleep 1; echo "avd name"} | telnet. This has exactly the same output: it fails on OS X and succeeds sometimes on Debian.

Please give me a hint: what's with this different behaviour? Why it is so unstable?

Community
  • 1
  • 1
Dumoko
  • 2,614
  • 3
  • 25
  • 34

1 Answers1

1

After some more research, I've found that NetCat is very powerful and useful, and is present on *NIX based systems.

Here is a fast, clean, reliable solution to get the name of the running AVD:

echo "avd name" | nc -w 1 localhost 5554
Dumoko
  • 2,614
  • 3
  • 25
  • 34