Libraryless. Click here for Pure Java version (602L/5K/16K).
1 | !747 |
2 | |
3 | main { |
4 | psvm { |
5 | String s = backtick("ip route show"); |
6 | List<String> lines = toLines(s); |
7 | new TreeSet<String> ips; |
8 | for (String line : lines) { |
9 | if (line.indexOf("via") >= 0) |
10 | ips.addAll(matchAll("\\d+\\.\\d+\\.\\d+\\.\\d+", line)); |
11 | } |
12 | if (ips.isEmpty()) System.out.println("No gateways found."); |
13 | for (String ip : ips) { |
14 | System.out.println("Possible gateway found: " + ip); |
15 | try { |
16 | String page = loadHomepage(ip); |
17 | System.out.println("Home page of device follows\n"); |
18 | System.out.println(page); |
19 | } catch (Throwable e) { |
20 | System.out.println("Could not load home page of " + ip + "."); |
21 | } |
22 | } |
23 | } |
24 | |
25 | static String loadHomepage(String ip) tex { |
26 | return loadPage("http://" + ip + ":8888"); |
27 | } |
28 | } |
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: | 783 / 874 |
Referenced in: | [show references] |