| 1 | package main |
| 2 | |
| 3 | import "github.com/ThomasRooney/gexpect" |
| 4 | import "fmt" |
| 5 | |
| 6 | func main() { |
| 7 | fmt.Printf("Starting python.. \n") |
| 8 | child, err := gexpect.Spawn("python") |
| 9 | if err != nil { |
| 10 | panic(err) |
| 11 | } |
| 12 | fmt.Printf("Expecting >>>.. \n") |
| 13 | child.Expect(">>>") |
| 14 | fmt.Printf("print 'Hello World'..\n") |
| 15 | child.SendLine("print 'Hello World'") |
| 16 | child.Expect(">>>") |
| 17 | |
| 18 | fmt.Printf("Interacting.. \n") |
| 19 | child.Interact() |
| 20 | fmt.Printf("Done \n") |
| 21 | child.Close() |
| 22 | } |