Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

28
LINES

< > BotCompany Repo | #712 // Linux+Android: Find gateway (e.g. your phone) and connect to it

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (602L/5K/16K).

!747

main {
  psvm {
    String s = backtick("ip route show");
    List<String> lines = toLines(s);
    new TreeSet<String> ips;
    for (String line : lines) {
      if (line.indexOf("via") >= 0)
        ips.addAll(matchAll("\\d+\\.\\d+\\.\\d+\\.\\d+", line));
    }
    if (ips.isEmpty()) System.out.println("No gateways found.");
    for (String ip : ips) {
      System.out.println("Possible gateway found: " + ip);
      try {
        String page = loadHomepage(ip);
        System.out.println("Home page of device follows\n");
        System.out.println(page);
      } catch (Throwable e) {
        System.out.println("Could not load home page of " + ip + ".");
      }
    }
  }
  
  static String loadHomepage(String ip) tex {
    return loadPage("http://" + ip + ":8888");
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, cmhtpxxajurv, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, mrjhfnjfopze, nrtiiiyxqhmw, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #712
Snippet name: Linux+Android: Find gateway (e.g. your phone) and connect to it
Eternal ID of this version: #712/1
Text MD5: 978bcaee12fa9f69fa768ee0a2a65938
Transpilation MD5: 76a2eca9a2cf919a7f1576a9d9f4d615
Author: stefan
Category: javax android
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-09-28 17:28:35
Source code size: 815 bytes / 28 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 646 / 682
Referenced in: [show references]