File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ /** *****************************************
2+ *
3+ * Get 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
6+ *
7+ * Run script
8+ * $ ./amm fucking-coffee.scala
9+ *
10+ *******************************************/
11+
12+ import java .net ._
13+ import java .io ._
14+ import ammonite .ops ._
15+ import ammonite .ops .ImplicitWd ._
16+
17+ val coffeeMachineIP = " 10.10.42.42"
18+ val password = " 1234"
19+ val passwordPrompt = " Password: "
20+ val delayBeforeBrew = 17
21+ val delay = 24
22+
23+ if ((%% who " -q" ).out.string.contains(sys.props(" user.name" ))) {
24+
25+ val telnet = new Socket (coffeeMachineIP, 23 )
26+ val out = new PrintWriter (telnet.getOutputStream, true )
27+ val in = new BufferedReader (new InputStreamReader (telnet.getInputStream))
28+
29+ println(s " Wait for $delayBeforeBrew seconds " )
30+ Thread .sleep(delayBeforeBrew * 1000 );
31+
32+ if (in.readLine == passwordPrompt){
33+ out.println(password)
34+
35+ out.println(" sys brew" )
36+ Thread .sleep(delay * 1000 )
37+ out.println(" sys pour" )
38+
39+ }
40+
41+ out.close()
42+ in.close()
43+ telnet.close()
44+
45+ }
You can’t perform that action at this time.
0 commit comments