File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ /** *****************************************
2+ *
3+ * Get and run Ammonite (http://lihaoyi.github.io/Ammonite/#Ammonite-Shell):
4+ * $ mkdir ~/.ammonite; curl -L -o ~/.ammonite/predef.scala http://git.io/vR04f
5+ * $ curl -L -o amm http://git.io/vR08A; chmod +x amm; ./amm
6+ *
7+ * Run script:
8+ * @ load.exec("fucking-coffee.scala")
9+ *
10+ *******************************************/
11+
12+ import java .net ._
13+ import java .io ._
14+ import ammonite .ops ._
15+
16+ val coffeeMachineIP = " 10.10.42.42"
17+ val password = " 1234"
18+ val passwordPrompt = " Password: "
19+ val delayBeforeBrew = 17
20+ val delay = 24
21+
22+ if ((%% who " -q" ).out.string.contains(sys.props(" user.name" ))) {
23+
24+ val telnet = new Socket (coffeeMachineIP, 23 )
25+ val out = new PrintWriter (telnet.getOutputStream, true )
26+ val in = new BufferedReader (new InputStreamReader (telnet.getInputStream))
27+
28+ Thread .sleep(delayBeforeBrew * 1000 );
29+
30+ if (in.readLine == passwordPrompt){
31+ out.println(password)
32+
33+ out.println(" sys brew" )
34+ Thread .sleep(delay * 1000 )
35+ out.println(" sys pour" )
36+
37+ }
38+
39+ out.close()
40+ in.close()
41+ telnet.close()
42+
43+ }
You can’t perform that action at this time.
0 commit comments