Skip to content

Commit

Permalink
Example RedHatOfficial#4: Python interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
tisnik committed Nov 27, 2019
1 parent 76dbdde commit 33e04cc
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions testing/go-expect/04_telnet_game.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"log"
"os"
"os/exec"
"time"

expect "github.com/Netflix/go-expect"
)

func main() {
console, err := expect.NewConsole(expect.WithStdout(os.Stdout))
if err != nil {
log.Fatal(err)
}
defer console.Close()

command := exec.Command("telnet", "zombiemud.org")
command.Stdin = console.Tty()
command.Stdout = console.Tty()
command.Stderr = console.Tty()

err = command.Start()
if err != nil {
log.Fatal(err)
}

time.Sleep(time.Second)
console.ExpectString("... online since 1994")
console.ExpectString("Your choice or name:")
console.Send("d\n")
console.ExpectString("Ok, see you later!")

err = command.Wait()
if err != nil {
log.Fatal(err)
}
}

0 comments on commit 33e04cc

Please sign in to comment.