| 1 | package main |
| 2 | |
| 3 | import gexpect "github.com/ThomasRooney/gexpect" |
| 4 | import "log" |
| 5 | |
| 6 | func main() { |
| 7 | log.Printf("Testing Ftp... ") |
| 8 | |
| 9 | child, err := gexpect.Spawn("ftp ftp.openbsd.org") |
| 10 | if err != nil { |
| 11 | panic(err) |
| 12 | } |
| 13 | child.Expect("Name") |
| 14 | child.SendLine("anonymous") |
| 15 | child.Expect("Password") |
| 16 | child.SendLine("[email protected]") |
| 17 | child.Expect("ftp> ") |
| 18 | child.SendLine("cd /pub/OpenBSD/3.7/packages/i386") |
| 19 | child.Expect("ftp> ") |
| 20 | child.SendLine("bin") |
| 21 | child.Expect("ftp> ") |
| 22 | child.SendLine("prompt") |
| 23 | child.Expect("ftp> ") |
| 24 | child.SendLine("pwd") |
| 25 | child.Expect("ftp> ") |
| 26 | log.Printf("Success\n") |
| 27 | } |