0

I want to be able to make telnet calls to an Android device, for giving it a geo location similar to this answer in "How to emulate GPS location in the Android Emulator?".

I tried using the Net::Telnet class in Ruby, and this code does seem to be doing it:

require 'net/telnet'     
telnet = Net::Telnet::new( "Host" => "localhost",
                           "Port" => 5554,
                           "Timeout" => 90 )
telnet.puts("geo fix -122.326 47.633")

I am not receiving any errors but the app doesn't get the location.

When I am running this in terminal I do not close the session, so how do I do to the same through Ruby?

Community
  • 1
  • 1
satyajit
  • 1,470
  • 3
  • 22
  • 43

1 Answers1

0

When you telnet in manually, you hit return after trying in the command, you need to add a newline to your command.

telnet.puts("geo fix -122.326 47.633\n")

I'm not sure if there is a response to geo, but if you want to display that you can use this form:

telnet.cmd("geo fix -122.326 47.633\n") {|c| print c}
Shawn Balestracci
  • 7,380
  • 1
  • 34
  • 52