2
0
mirror of https://github.com/narkoz/hacker-scripts synced 2025-08-23 19:07:33 +00:00

Run script from bash

This commit is contained in:
Amir Karimi 2015-12-07 14:54:43 +03:30
parent 7d11758390
commit 895b9228d3

View File

@ -1,17 +1,18 @@
/******************************************* /*******************************************
* *
* Get and run Ammonite (http://lihaoyi.github.io/Ammonite/#Ammonite-Shell): * Get Ammonite (http://lihaoyi.github.io/Ammonite/#Ammonite-Shell):
* $ mkdir ~/.ammonite; curl -L -o ~/.ammonite/predef.scala http://git.io/vR04f * $ mkdir ~/.ammonite; curl -L -o ~/.ammonite/predef.scala http://git.io/vR04f
* $ curl -L -o amm http://git.io/vR08A; chmod +x amm; ./amm * $ curl -L -o amm http://git.io/vR08A; chmod +x amm
* *
* Run script: * Run script
* @ load.exec("fucking-coffee.scala") * $ ./amm fucking-coffee.scala
* *
*******************************************/ *******************************************/
import java.net._ import java.net._
import java.io._ import java.io._
import ammonite.ops._ import ammonite.ops._
import ammonite.ops.ImplicitWd._
val coffeeMachineIP = "10.10.42.42" val coffeeMachineIP = "10.10.42.42"
val password = "1234" val password = "1234"
@ -25,6 +26,7 @@ if ((%%who "-q").out.string.contains(sys.props("user.name"))) {
val out = new PrintWriter(telnet.getOutputStream, true) val out = new PrintWriter(telnet.getOutputStream, true)
val in = new BufferedReader(new InputStreamReader(telnet.getInputStream)) val in = new BufferedReader(new InputStreamReader(telnet.getInputStream))
println(s"Wait for $delayBeforeBrew seconds")
Thread.sleep(delayBeforeBrew * 1000); Thread.sleep(delayBeforeBrew * 1000);
if(in.readLine == passwordPrompt){ if(in.readLine == passwordPrompt){