循环执行shell命令
(s string)
| 62 | |
| 63 | // 循环执行shell命令 |
| 64 | func loopCmd(s string) { |
| 65 | Info("执行命令") |
| 66 | reader := bufio.NewReader(os.Stdin) |
| 67 | for { |
| 68 | fmt.Print("$ ") |
| 69 | cmd, _ := reader.ReadString('\n') |
| 70 | cmd = strings.TrimRight(cmd, "\r\n") |
| 71 | if cmd == "exit" || cmd == "q" || cmd == "quit" { |
| 72 | if strings.Contains(s, "exec") { |
| 73 | CloseSlave("exec") |
| 74 | } |
| 75 | break |
| 76 | } |
| 77 | // 执行命令 |
| 78 | if strings.Contains(s, "exec") { |
| 79 | RunCmd(cmd) |
| 80 | } else if strings.Contains(s, "lua") { |
| 81 | RedisLua(cmd) |
| 82 | } |
| 83 | |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | // 循环执行 Redis 命令 |
| 88 | func loopRedis() { |
no test coverage detected