Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import sys.process._
object search {
def main: Option[String] = {
retry2(iphone)
}
def iphone: Option[String] = {
val ping = try {
Process("ping -c 5 192.168.0.20") #&& ("echo okkk") !!
} catch {
case e: Throwable => "error"
}
if (ping == "okkk") Some("家にいます") else None
}
def retry2[R](f: => R, n: Int = 40): R = {
if (n > 0) {
f match {
case Some(s) => f
case None => retry2(f, n - 1)
}
} else f
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.