0
有一個簡單的Groovy腳本如下(非常格式化):使用expect.Expect對Groovy到特定端口上的SSH連接
import com.santaba.agent.groovyapi.expect.Expect
def hostname = hostProps.get("system.hostname")
cli = Expect.open(hostname, "user", "pass")
cli.expect("*** Welcome to pfSense ")
cli.send("8\n")
cli.expect("root(1): ")
cli.send("relayctl show hosts\n")
cli.expect("root(2): ")
cli.before().eachLine { line ->
if (line =~ /host/) {
tokens = line.split(/\s+/)
println tokens[5]
}
}
cli.send("exit\n")
cli.close()
什麼我不能做的就是在港口通過我想例如:8331.
是否有可能實現此目的?謝謝!